One, foreword
1. What is Jenkins?
Jenkins is an open source platform that supports automated build, deployment, and other tasks. It is basically an indispensable tool for continuous integration (CI) and continuous publishing (CD).
Liverpoolfc.tv: Jenkins. IO /
2. Environmental information of this article
Tools/Environment | version |
---|---|
Linux Server | CentOS 7 |
Jenkins | 2.233.1 |
JDK | 1.8.0 comes with _181 |
3. Preparation
- Install the JDK
Reference: juejin. Cn/post / 684490…
After deployment, the JDK root directory is /usr/java/jdk1.8.0_181/
Two, Jenkins installation
1. Yum install
- Yum source import
# add Yum source
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
# import key
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
Copy the code
- The installation
sudo yum install jenkins
Copy the code
2. Open ports
The default listening port for the Jenkins site is 8080
sudo firewall-cmd --add-port=8080/tcp --permanent
sudo firewall-cmd --reload
Copy the code
Method 2 vim /etc/sysconfig/jenkins# monitor port
JENKINS_PORT="8080"Copy the code
To avoid all sorts of permissions issues, use root directly here
Example Change the user name to root
vim /etc/sysconfig/jenkins
# change configuration
$JENKINS_USER="root"Copy the code
Modifying Directory Permissions
chown -R root:root /var/lib/jenkins
chown -R root:root /var/cache/jenkins
chown -R root:root /var/log/jenkinsCopy the code
restart
service jenkins restart
ps -ef | grep jenkins
Reload all modified configuration files
sudo systemctl daemon-reload
Copy the code
3. Configure optional Java paths
Because the Jenkins default Java optional path does not contain the JDK path we deployed, it is necessary to configure it here, otherwise the Jenkins service will fail to start
# Change the Jenkins startup script
sudo vi /etc/init.d/jenkins
/usr/ Java /jdk1.8.0_181/bin/ Java
candidates="/ etc/alternatives/Java/usr/lib/JVM/Java - 1.8.0 comes with/bin/Java/usr/lib/JVM/jre - 1.8.0 comes with/bin/Java /usr/lib/jv/jre-1.7.0 /bin/java /usr/lib/jv/jre-1.7.0 /bin/java /usr/bin/java /usr/jv/jdk1.8.0_181 /bin/java"
Copy the code
4. Start Jenkins and set Jenkins to boot
# Reload service (due to previous changes to Jenkins startup script)
sudo systemctl daemon-reload
# Start Jenkins service
sudo systemctl start jenkins
Set Jenkins service to boot
# Since Jenkins is not a Native Service, use the chkconfig command instead of the systemctl command
sudo /sbin/chkconfig jenkins on
Copy the code
Enter http://< IP address>:8080 in your browser to access Jenkins