④:gitlab of continuous integration triggers Jenkins build project
One: The goal is in the company's test environment once the development to the Gitlab warehouse to submit a successful code, Gitlab notify Jenkins to build projects, code quality testing and then deployed to the test environment, note that this is a test environment, and production environment still need to manually deploy code:
1.1:jenkins configuration:
1.1.1: Install Gitlab Hook Plugin plugin:
#系统管理-Admin Plug-in-optional plugins-gitlab Hook Plugin and build Authorization Token Root Plugin
1.1.2: Generate Random token:
# OpenSSL Rand-hex
0f2a47c861133916d2e299e3
1.1.3: Create a project trigger:
#项目-Configuration-build triggers:
Http://192.168.3.199:8080/jenkins/project/web-demo
1.2: Configure GitHub:
1.2.1: Set up links and token in the GIT project configuration interface:
Login Gitlab, find the hook configuration under this project
#选择项目-Set-webhooks:
#插件使用介绍, Https://wiki.jenkins-ci.org/display/JENKINS/Build+Token+Root+Plugin.
Http://192.168.3.199:8080/jenkins/buildByToken/build?job=web-demo&token=0f2a47c861133916d2e299e3
Http://jenkins Server address: 8080/buildbytoken/build?job= Project name &token=token value
1.2.2: Test:
Error:
Hook executed successfully but returned HTTP 404
This is because the path is not added to the Jenkins behind the project
1.2.2: Test, see show 201 indicates success
1.3: Submit code to GIT server to verify that it can be deployed automatically:
1.3.1: Submit Code:
[Www@master code]$ git clone git@192.168.3.198:web/web-demo.git
[Www@master web-demo]$ echo ' Build token root plugin "> Index.html
[www@master web-demo]$ git add ' index.html '
[www@master web-demo]$ git commit-m ' build token ro OT plugin test '
[master BEB37CB] Build token root plugin test
1 file changed, 1 insertion (+), 1 deletion (-)
[w Ww@master web-demo]$ git push origin master
counting Objects:5, done.
Compressing objects:100% (2/2), done.
Writing objects:100% (3/3), 281 bytes | 0 bytes/s, done.
Total 3 (Delta 1), reused 0 (Delta 0) to
git@192.168.3.198:web/web-demo.git
c02523b. BEB37CB Master-> Master
Log records for 1.3.2:jenkins servers:
[Root@node1 tomcat]# tail-f/usr/local/tomcat/logs/catalina.out
1.3.3:jenkins Project Construction:
1.3.4: Access the Web interface to verify that the code is up to date:
1.3.5:jenkins Console Output Information: