给自己的爱人做网站太仓网站建设教程
配置环境
虚拟机建议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主机新建公私钥
[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命令,点击保存

点击构建

 点击控制台输出
整合完毕,查看输出结果
 
