First, Java JDK installation

Before installing, check whether your system has the open-JDK shipped with it

Command:

rpm -qa |grep javaCopy the code

rpm -qa |grep jdkCopy the code

rpm -qa |grep gcj
Copy the code

If no information is entered, the installation is not complete.

If the installation can use RPM – qa | grep Java | xargs RPM -e — nodeps batch uninstall all files with Java This keyword is a Java command

First, retrieve the list that contains Java

Yum install java-1.8.0 -openJDK * -y Install java-1.8.0 -openJDK * -y install java-1.8.0 -openJDK * -y This completes the installation. One advantage of this installation is that you don’t need to set the path, it is set automatically


Ii. Jenkins installation and configuration

Install Jenkins

1. Download dependencies

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

2. Import the key

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

3. The installation

yum install jenkins

4. Find the Jenkins installation path

rpm -ql jenkins

Jenkins

  • /usr/lib/jenkins/: Jenkins installation directory, where the WAR package will be placed

  • /etc/sysconfig/jenkins: Jenkins profile, “port”, “JENKINS_HOME” etc can be configured here.

  • /var/lib/jenkins/: The default JENKINS_HOME.

  • /var/log/jenkins/jenkins.log: Jenkins log file.


Initialize the Jenkins server

1. Edit the Jenkins profile

In order to avoid any problems with permissions, change the user name to root.

vim /etc/sysconfig/jenkins

 $JENKINS_USER="root"

2. Modify Jenkins ports

If port 8080 is not occupied by default, do not change the value.
If the port is already occupied, change the port to another port and open the corresponding port.

3. Start Jenkins

It is recommended to start Jenkins service with screen tool, which can run in the background without worrying about service stop caused by remote port shutdown. The specific usage of screen is not expanded here, you can refer to:
Juejin. Cn/post / 684490…

Start the Jenkins

java -jar /usr/lib/jenkins/jenkins.war --httpPort=8899

Start Jenkins with Screen (Jenkins1 is the name of the session created for the Jenkins service)

screen -S jenkins1 java -jar /usr/lib/jenkins/jenkins.war --httpPort=8899

Separated screen background run Jenkins:

First control + A, then D

List all current sessions:

screen -ls

You can see the Jenkins service running in the background, even if the server logout is disabled, the Jenkins service is still available.



4. Visit Jenkins’ address

Enter http://[server IP address]:[port number] in the browser.

If successfully started, the Jenkins Unlock page will appear.

Enter the command to obtain the password

cat /var/lib/jenkins/secrets/initialAdminPassword

Then follow the steps on the page: Unlock Jenkins -> install the recommended plugin -> Create your first administrator account

You can also use the admin account to create an administrator account. You need to enter the password obtained above.

Now you can use Jenkins.