3、所有的插件都下载完成,先别急着勾选Restart Jenkins when installation is complete and no jobs are running。点击左侧的Manage Pluagins---Manage Plugins,回到插件管理页面,点击Available,在Filter 中输入如下插件并选中:GitLab Plugin、Git client plugin、GitLab Hook Plugin、Git plugin、SonarQube Plugin、Pubish Over SSH(批量发布登录插件)。最后点击 Download now and install after restart:
4、此时可以看到回到了上面升级插件的页面继续下载刚刚选中要安装的插件,这一次,我们就勾选 Restart Jenkins when installation is complete and no jobs are running:
7、由上面的gitlab 可知,我们的仓库中已经有了1.txt 这个文件,现在,我们来编辑该文件,添加一些内容:
Linuser@DESKTOP-K8HE3J4 MINGW64 /e/test/project-test (master)
$ echo 'Test Jenkins auto build' > 1.txt
现在我们来提交并推送到gitlab , 看jenkins 会不会自动构建:
Linuser@DESKTOP-K8HE3J4 MINGW64 /e/test/project-test (master)
$ git add .
warning: LF will be replaced by CRLF in 1.txt.
The file will have its original line endings in your working directory.
Linuser@DESKTOP-K8HE3J4 MINGW64 /e/test/project-test (master)
$ git commit -m 'change 1.txt'
[master warning: LF will be replaced by CRLF in 1.txt.
The file will have its original line endings in your working directory.
907b4b9] change 1.txt
warning: LF will be replaced by CRLF in 1.txt.
The file will have its original line endings in your working directory.
1 file changed, 1 insertion(+), 1 deletion(-)
Linuser@DESKTOP-K8HE3J4 MINGW64 /e/test/project-test (master)
$ git push
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 281 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@node02.com:root/project-test.git
d109723..907b4b9 master -> master
同时在Jenkins 的项目中可以看到有构建了:
点击构建历史,进入看下构建日志(没发邮件,是因为上面勾选了Send e-mail for every unstable build):
登录Jenkins 服务器,查看工作目录下的的1.txt 的内容;
[root@node03 ~ 11:01:48]#cat /data/jenkins/workspace/project-test/1.txt
Test Jenkins auto build
8、更改变更自动构建为定时构建,就是多长时间它自动去构建一次,如下(我们在上面这个项目的基础上将之前的uild when a change is pushed to GitLab 去掉,改选Build periodically,然后做定时):
为了区分构建,这里我把构建后操作发送的邮件取消,这样一旦构建就会发送邮件了
下面,我们在windows 上的仓库目录中1.txt 文件中新增一点内容,然后推送到服务器端:
Linuser@DESKTOP-K8HE3J4 MINGW64 /e/test/project-test (master)
$ echo '10 minute auto build' >> 1.txt
Linuser@DESKTOP-K8HE3J4 MINGW64 /e/test/project-test (master)
$ git add .
warning: LF will be replaced by CRLF in 1.txt.
The file will have its original line endings in your working directory.
Linuser@DESKTOP-K8HE3J4 MINGW64 /e/test/project-test (master)
$ git commit -m 'change'
[master warning: LF will be replaced by CRLF in 1.txt.
The file will have its original line endings in your working directory.
3d86eb7] change
warning: LF will be replaced by CRLF in 1.txt.
The file will have its original line endings in your working directory.
1 file changed, 1 insertion(+)
Linuser@DESKTOP-K8HE3J4 MINGW64 /e/test/project-test (master)
$ git push
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 298 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@node02.com:root/project-test.git
0e5337b..3d86eb7 master -> master
代码推送后,很明显没有自动构建了:
等待几分钟,会发现:
再次看服务器上的1.txt 文件:
[root@node03 ~ 13:28:21]#cat /data/jenkins/workspace/project-test/1.txt
Test Jenkins auto build
10 minute auto build
如果需要发布代码只要在系统配置里面的管理节点里新建节点,这里就不详细介绍了,java发布的话需要安装私服(maven)