A, Jenkins Overview
Second, the installation Jenkins
https://pkg.jenkins.io/redhat-stable/ sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key yum install jenkins
Related packages introduced
/ usr / lib / Jenkins / jenkins.war the WAR bag / etc / sysconfig / Jenkins profile / var / lib / jenkins / default directory JENKINS_HOME /var/log/jenkins/jenkins.log Jenkins log file
Configuration and startup
[root@jspgou ~]# lsof -i:8080 [root@jspgou ~]# /etc/init.d/jenkins start Starting jenkins (via systemctl): [ OK ] [root@jspgou ~]# lsof -i:8080 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME java 26969 jenkins 162u IPv6 68624 0t0 TCP *:webcache (LISTEN) [root@jspgou ~]# rpm -qa | grep jenkins jenkins-2.107.1-1.1.noarch [root@jspgou ~]# rpm -ql jenkins /etc/init.d/jenkins /etc/logrotate.d/jenkins /etc/sysconfig/jenkins /usr/lib/jenkins /usr/lib/jenkins/jenkins.war /usr/sbin/rcjenkins /var/cache/jenkins /var/lib/jenkins /var/log/jenkins [root@jspgou ~]#
Log in your browser, the initial password in the file as follows:
[root@jspgou ~]# cat /var/lib/jenkins/secrets/initialAdminPassword 389c09a28ecb42fe871a82d4414c5472 [root@jspgou ~]#
Third, configure Jenkins in the WEB
log in
System Management - add plug-ins
Add ssh, maven and other related plug-ins
以下插件需要选择安装
Ansible plugin
Ant Plugin
Blue Ocean
Build Timeout
Email Extension Plugin
Git Parameter Plug-In
Gitlab Hook Plugin
GitLab Plugin
Maven Invoker plugin
Maven Integration plugin
Publish Over SSH
SSH plugin
SSH Slaves plugin
The method is shown below:
System Management - System Configuration
System Configuration - Specifies administrator-mail address
System Configuration - Set mail notification SMTP server and its associated configuration
System Configuration - Setting remote SSH server address and configuration
If you need to specify the private key file, but also need to be copied to a private / var / lib / jenkins directory as follows:
mkdir .ssh
cp ~/.ssh/id_rsa .ssh/
chown -R jenkins.jenkins .ssh
As shown below:
System Management - Global Configuration Tool
Global Configuration Tools - Configure jdk
Global Configuration Tools - Configure maven
Creating a user Jenkins in Gitlab:
Jenkins and added to the corresponding user group (Group)
Add relevant Credentials in Jenkins in:
Jenkins will Gitlab in the user's username and password to fill in Credentials:
Jenkins created the project (Example 1):
Configuration item git server
Add Access git server's ssh key (private key)
Construction configuration item (using maven build the package)
Construction of the action configuration item
Building on the configuration completed projects
View this building process
Build reports
Creating Project Jenkins (Example 2):
First, add the code for the Tag using git, as follows:
[eric@meteor maven01]$ vim src/main/java/inspiry/cn/maven/HelloWorld.java
[eric@meteor maven01]$ git add .
[eric@meteor maven01]$ git commit -m 'stable branch'
[stable 4cfc2e3] stable branch
1 file changed, 1 insertion(+)
[eric@meteor maven01]$ git tag v1.0.2
[eric@meteor maven01]$ git tag
v1.0.2
[eric@meteor maven01]$ git push -u origin stable
Counting objects: 17, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (9/9), 583 bytes | 0 bytes/s, done.
Total 9 (delta 2), reused 0 (delta 0)
remote:
remote: To create a merge request for stable, visit:
remote: http://192.168.60.119/plat-sp/maven01/merge_requests/new?merge_request%5Bsource_branch%5D=stable
remote:
To [email protected]:plat-sp/maven01.git
* [new branch] stable -> stable
Branch stable set up to track remote branch stable from origin.
[eric@meteor maven01]$
[eric@meteor maven01]$ git branch
master
* stable
[eric@meteor maven01]$ git push origin v1.0.2
Total 0 (delta 0), reused 0 (delta 0)
To [email protected]:plat-sp/maven01.git
* [new tag] v1.0.2 -> v1.0.2
[eric@meteor maven01]$
You can then view the Tag in gitlab in:
Jenkins then set to add the following items:
Select "Parametric building process", as follows:
Specifies gitlab warehouse using http mode, and select the relevant read permission credentials comprising, as follows:
Select the build environment "before building deleted workspace"
Select the name of the global MAVEN build process settings and parameters are specified as follows:
. Construction after target / * jar package pushed to a specified directory SSH server and execute scripts or shell statement as follows:
When the selection item constructed Tag Specifies constructed as follows:
Construction of the results are as follows:
Transfer from
Jenkins Getting -WorkNote-51CTO blog https://blog.51cto.com/caiyuanji/2118330