Jenkins和Gitlab整合构建CI/CD流水线

配置环境

虚拟机建议4G起步

192.168.58.199

192.168.58.200

部署Jenkins

部署Jenkins参考这篇文章:Jenkins安装部署_connecting to pkg.jenkins.io (pkg.jenkins.io)|151.-CSDN博客

安装完毕之后根据下图操作

选择git,添加git仓库克隆url,选择私钥

Gitlab上的操作

选择新建项目

创建空白项目

新建项目完成之后,添加SSH连接公钥

分别在199主机和200主机新建公私钥

bash 复制代码
[root@pro ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Passphrases do not match.  Try again.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:W8Vj9eu9V+u6uKcZFisN17calbSjZMXSuuLgCOek1RY root@pro
The key's randomart image is:
+---[RSA 2048]----+
|              .  |
|           . .o. |
|            =. =.|
|           o..= +|
|        SE.o = B |
|        .o= = * =|
|     . +.= * + o+|
|      B + = =.o.o|
|     . o . *+++o.|
+----[SHA256]-----+

将新建的公私钥添加到Gitlab上

选择刚刚新建的项目test-jenins3,复制克隆地址

返回Jenkins操作

将复制的地址粘到此处

注意在Jenkins上要添加解密私钥,添加方法自己研究

让Jenkins每分钟检查一次gitlab有没有更新

添加执行shell命令,点击保存

点击构建

点击控制台输出

整合完毕,查看输出结果

相关推荐
不吃香菜kkk、6 天前
CI/CD(GitOps)学习与部署手册
运维·云原生·容器·kubernetes·云计算·jenkins·argocd
Ticnix7 天前
别再手动上线了:一条命令带备份、健康检查和自动回滚
后端·python·ci/cd
zoutao988 天前
Gitea Actions 自定义 Runner 镜像与自动化部署实战
ci/cd·docker·gitea
troy1288 天前
Codex 安全盲区:代码漏洞生成实测
windows·python·ci/cd·pycharm·django·github·fastapi
daemon.qiang9 天前
国内虚拟机对接 Freedesktop:Fork xserver、自建 Runner 与提交 MR 实战
linux·ubuntu·centos·gitlab·开源软件
极小狐10 天前
CI 算力饥渴症:Runner 弹性伸缩的架构权衡与落地
ci/cd·kubernetes·devops·弹性伸缩
qq_3494479511 天前
Ubuntu26安装jenkins
jenkins
蓝天星空11 天前
Jenkins项目矩阵授权配置
jenkins
szephyr12 天前
GitHub Actions 实战:给个人项目接上免费的自动部署流水线
ci/cd·github·devops·自动化部署·github actions
Patrick_Wilson12 天前
桌面端发布的真实成本:签名、公证和那支不能共享的 USB Key
ci/cd·electron·客户端