Jenkins installation tutorial
To install Jenkins, you will need to install Docker and JDK. If you have not already installed Docker or JDK, please refer to the additional documentation — Docker Setup and JDK Setup
1. Add Jenkins library to yum repos:
wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
2. Grab resources
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
3. Install the Jenkins
yum install -y jenkins
4. Configuration Jenkins
Open Jenkins text and go into edit mode
vi /etc/sysconfig/jenkins
Change USER to root and port to a non-conflicting port
For example, if I have an 8085, I will change the 8080 after the port to 8085
5. Start Jenkins
Enter the following command to start Jenkins
service jenkins restart
5.1 Successful startup
5.2 Start Failure
Here is a problem with the Jenkins JDK configuration, using the following command to open the document for editing
vi /etc/init.d/jenkins
Add your own JDK path to /usr/bin/java.
When you restart Jenkins after the addition is complete, 5.1 will start successfully
service jenkins restart
6. Open ports
Log on to our server, go to Security Group – click Configuration Rules
In the configuration rules, manually add the port we just set in step 4, fill in the port range just set, for example, mine is 8085/8085, the default source is 0.0.0.0/0, you can decide whether to add the description, and then save it
7. Unlock Jenkins
7.1 Unlock it for the first time, open a browser on Windows or Mac native, and type “IP: Port “to unlock (assuming the server’s public network IP is 192.168.1.1 and the newly opened port is 8085), then enter 192.168.1.1:8085 in the browser and enter the Jenkins unlocking interface (if there is an error in the input, you can check whether the server is open or not. Is the port number developed in the security group consistent with the port number in Step 4? If no problem is found, you can enter the 7.2 pagoda to solve the problem of not logging in Jenkins.)
If you successfully log in the unlock interface, enter the following interface
Find the relevant file according to the red path, enter the password in the file into the text box (after remote connection, click the top left corner of the file to open the number of files, you can also use the Tower “file”), find the file, double click to open, copy the content into the text box
If the file cannot be found, you can copy the administrator password by opening the document directly with the following command line
If I put it in a different place, it’s vi (red path)
vi /var/lib/jenkins/secrets/initialAdminPassword
After the input is completed, enter the following interface, recommend to use the recommended plug-in installation, wait for the installation is completed
After the installation is complete, create the first administrator user and enter the user name, password and other information to proceed to the next step
After clicking Save and finishing, enter the following interface, Instance URL configuration, which is usually the same as the input when unlocking Jenkins. It is also the server IP: port number, so save by default
When the save is complete, the following screen appears and Jenkins is installed
This is the main screen
7.2 Pagoda solved the issue of not being able to log into Jenkins
It may be that this port of the firewall has not been successfully opened. We can enter the pagoda for setting. (If you do not know about pagoda or have not installed pagoda before, you can refer to another document — the installation and use of pagoda)
7.3 Some users may not speak Chinese, you can choose Chinese, click the left gear icon, and then click the green icon on the right
Select the second optional plug-in, search for Locale, Download, and then click Restart. Restart Jenkins when the download is complete
Some versions of Jenkins may also need to install another plug-in Localization: Chinese
If it has not yet become Chinese, you may need to install the plugin. If it does, you may be missing the plugin. (Note that you must restart Jenkins after the installation. Remember that! Remember!)