centos installs jenkins and configures flash for automatic publishing

Automatic deployment has come. Although it has been done before and now, it has not been sorted into notes. There are thousands of pits on the Internet, with jenkins installation

The first step is to install jenkins. You need to install jdk first

yum search java|grep jdk
yum install java-1.8.0-openjdk
source /etc/profile


Step 2 download dependency

wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo --no-check-certificate

Step 3 import the secret key

rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

Step 4  

yum  -y install epel-release
yum -y install daemonize
yum install jenkins

But install jenkins May fail
 The picture above is Jenkins The installation method recommended in the official documents, but this method has two disadvantages
 1:  Installed is Jenkins The latest version, cannot customize the installed version
 2:  Using foreign image source, the download speed is very slow

The solution is to select the image source of the domestic node and enter any node Jenkins Domestic node, select the required version and right-click to copy its link directly
Jenkins Huawei image source   https://mirrors.huaweicloud.com/jenkins/redhat-stable/ 
Jenkins Image source of Tsinghua University   https://mirror.tuna.tsinghua.edu.cn/jenkins/redhat-stable/
Jenkins Open source software image source  https://mirrors.cnnic.cn/jenkins/redhat-stable/
Jenkins Mirror source of Beijing Foreign Studies University  https://mirrors.bfsu.edu.cn/jenkins/redhat-stable/

install jenkins The first two are required before
yum -y install https://mirrors.huaweicloud.com/jenkins/redhat-stable/jenkins-2.303.3-1.1.noarch.rpm --skip-broken


Step 5 after the installation is successful, you can view the directory information

[root@analyse-test ~]# rpm -ql jenkins

1,jenkins Definition of relevant contents: 1. /usr/lib/jenkins/: jenkins Installation directory, war The bag will be here. two. /etc/sysconfig/jenkins: jenkins Configuration file, "port"“ JENKINS_HOME"You can configure it here. 3. /var/lib/jenkins/: default JENKINS_HOME. 4. /var/log/jenkins/jenkins.log: jenkins Log file.


Step 6

modify jenkins Port number  
vi /etc/sysconfig/jenkins
 The default port number is 8080. In order to prevent port conflicts, we need to modify the port number.

Here I change it to 5050

Step 7 set the startup self startup and start jenkins

chkconfig jenkins on
service jenkins start

Step 8: check the jenkins password, access the jenkins service using ip:port, and install the default configuration

visit jenkins Fill in the password on the page, the password is on the access page, and the initial password is on the/var/lib/jenkins/secrets/initialAdminPassword

Install the default configuration and wait for the installation


Then you can actually open the jenkins service, as shown in the following figure




So we simply configure a project

Select new task and enter a name








After the project is established, enter the project selection configuration

(1) Configure the reserved construction. I choose to save the construction history 10 times in recent 7 days

(2) Configure git account and select the corresponding branch to automatically pull




(3) Just configure the shell script, close the previous service and start the existing service. There is no screenshot here

After configuring the above construction points, you can actually succeed






ps, but you may encounter many problems. If you pull https, there is a certificate problem. You can pull it from the server, but jenkins will report the following error




  It can be handled like this

In the source code management of Jenkins new project, the error in entering the Repository URL is largely due to the use of the public-private key generated by root. In fact, it needs to be generated on the premise of logging in to the Jenkins account. However, Jenkins is automatically created by the system and has no login permission and does not know the password.
At this time, you need to change the password # sudo passwd jenkins for the j account first
Then modify the interpreter of jenkins account under / etc/passwd to / bin/bash
At this time, log in to the jenkins account, go to the / var/lib/jenkins/.ssh / directory, generate a new private key and public key through the SSK keygen command, add the public key to github, and configure the private key to jenkins publish over ssh.
After testing, the connection to github warehouse is normal, but coding.net is not.

Then the server switches the jenkins account su jenkins, and then the git command ignores https   


Tags: git jenkins Flask

Posted on Wed, 24 Nov 2021 05:35:13 -0500 by wood1e