A, Jenkins Overview
Jenkins Getting Started

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
Jenkins Getting Started

System Management - add plug-ins
Jenkins Getting Started

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:
Jenkins Getting Started

System Management - System Configuration
Jenkins Getting Started

System Configuration - Specifies administrator-mail address
Jenkins Getting Started

System Configuration - Set mail notification SMTP server and its associated configuration
Jenkins Getting Started

System Configuration - Setting remote SSH server address and configuration
Jenkins Getting Started

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:
Jenkins Getting Started

System Management - Global Configuration Tool
Jenkins Getting Started

Global Configuration Tools - Configure jdk
Jenkins Getting Started

Global Configuration Tools - Configure maven
Jenkins Getting Started

Creating a user Jenkins in Gitlab:
Jenkins Getting Started

Jenkins and added to the corresponding user group (Group)
Jenkins Getting Started

Add relevant Credentials in Jenkins in:
Jenkins Getting Started

Jenkins will Gitlab in the user's username and password to fill in Credentials:
Jenkins Getting Started

Jenkins created the project (Example 1):
Jenkins Getting Started

Configuration item git server
Jenkins Getting Started

Add Access git server's ssh key (private key)
Jenkins Getting Started

Construction configuration item (using maven build the package)
Jenkins Getting Started

Construction of the action configuration item
Jenkins Getting Started

Building on the configuration completed projects
Jenkins Getting Started

View this building process
Jenkins Getting Started

Build reports
Jenkins Getting Started

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]$ 

Jenkins Getting Started

You can then view the Tag in gitlab in:
Jenkins Getting Started

Jenkins then set to add the following items:
Jenkins Getting Started

Select "Parametric building process", as follows:
Jenkins Getting Started

Specifies gitlab warehouse using http mode, and select the relevant read permission credentials comprising, as follows:
Jenkins Getting Started

Select the build environment "before building deleted workspace"
Jenkins Getting Started

Select the name of the global MAVEN build process settings and parameters are specified as follows:
Jenkins Getting Started

. Construction after target / * jar package pushed to a specified directory SSH server and execute scripts or shell statement as follows:
Jenkins Getting Started

When the selection item constructed Tag Specifies constructed as follows:
Jenkins Getting Started

Construction of the results are as follows:
Jenkins Getting Started