Jenkins installation and deployment tutorial under CentOS 7

I. Introduction##

1、 What is Jenkins?

Jenkins is an open source platform that supports tasks such as automated construction and deployment. Basically, it can be said that it is an indispensable tool for continuous integration (CI) and continuous release (CD).

Official website: https://jenkins.io/

2、 Environmental information of this article###

Tools/Environment Version
Linux Server CentOS 7
Jenkins 2.121.2
JDK 1.8.0_181
Nginx 1.14.0

3、 Ready to work###

Reference: https://ken.io/note/centos-java-setup

Deploy jdk1.8.0_181 in the directory /usr/java/
After deployment, the root directory of jdk is: /usr/java/jdk1.8.0_181/

Reference: https://ken.io/note/centos-quickstart-nginx-setup

Nginx is deployed to facilitate our access to Jenkins through the domain name. If there is no such requirement, you can ignore this operation

Two, Jenkins installation##

1、 Yum installation###

# 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
sudo yum install -y jenkins

2、 Open port###

The default listening port of the Jenkins site is 8080

sudo firewall-cmd --add-port=8080/tcp --permanent
sudo firewall-cmd --reload

3、 Configure Java Optional Path###

Because Jenkins default java optional path does not include the jdk path we deployed, so we need to configure it here, otherwise the Jenkins service will fail to start

# Modify the jenkins startup script
sudo vi /etc/init.d/jenkins

# Modify candidates to add java optional path:/usr/java/jdk1.8.0_181/bin/java
candidates="
/etc/alternatives/java
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/lib/jvm/java-1.7.0/bin/java
/usr/lib/jvm/jre-1.7.0/bin/java
/usr/bin/java
/usr/java/jdk1.8.0_181/bin/java
"

4、 Start Jenkins and set Jenkins to boot

# Reload the service (because the Jenkins startup script was modified earlier)
sudo systemctl daemon-reload

# Start the Jenkins service
sudo systemctl start jenkins

# Set the Jenkins service to start on boot
# Since Jenkins is not a Native Service, you need to use the chkconfig command instead of the systemctl command
sudo /sbin/chkconfig jenkins on

Browser enter http://<ip address> :8080 Visit Jenkins

Three, Nginx configuration (non-essential steps)

1、 Configure Nginx reverse proxy Jenkins

# New Nginx configuration file for Jenkins
sudo vi /etc/nginx/conf.d/jenkins.conf

# Enter the following and save
server {
 listen       80;        #Listen on port 80
 server_name  jenkins.ken.io; #Listening domain
 access_log  /var/log/nginx/jenkins.access.log main;
 error_log  /var/log/nginx/jenkins.error.log error;

 location /{            #Forward or process
  proxy_pass http://127.0.0.1:8080;}
 error_page   500502503504/50x.html;#Error page
 location =/50x.html {
  root   /usr/share/nginx/html;}}
sudo nginx -s reload

2、 Configure SELinux

If you do not configure SELinux and access through Nginx reverse proxy, the following errors may occur

# View error message
/var/log/nginx/jenkins.error.log

# Examples of error messages
connect() to 127.0.0.1:8001failed(13: Permission denied)while connecting to upstream, client:127.0.0.1
# Turn off SELinux:
sed -i '/SELINUX/s/enforcing/disabled/'/etc/selinux/config 
# Restart:
reboot

Modify the local hosts, point the domain name jenkins.ken.io to the CentOS IP, and pass the domain name test access

Four, Jenkins initialization##

1、 Unlock Jenkins

Query the default password of the root account

cat /var/lib/jenkins/secrets/initialAdminPassword

Enter password and unlock

2、 Choose plugin###

Just select "Install recommended plug-ins" here

After selecting the installed plug-in, you will enter the plug-in installation interface

3、 Add administrator###

After the plug-in is installed, it will automatically enter the add administrator interface

4、 Configure Jenkins URL

The URL here refers to the address where Jenkins is accessed by default.
The default is http://:8080. If you have configured the domain name through Nginx, just fill in the configured domain name.

5、 Start using Jenkins

After configuring the Jenkins URL, the entire Jenkins configuration guide is completed

Click "Start using Jenkins" to enter the Jenkins homepage

Finished~

Five, remarks##

https://wiki.jenkins.io/display/JENKINS/Installing+Jenkins+on+Red+Hat+distributions

https://stackoverflow.com/questions/23948527/13-permission-denied-while-connecting-to-upstreamnginx?rq=1

Recommended Posts

Jenkins installation and deployment tutorial under CentOS 7
Erlang 20.2 installation and deployment under CentOS 7
MySQL 8.0 installation, deployment and configuration under CentOS 6/7
Zabbix installation and deployment and localization under CentOS
MySQL 8.0 installation and deployment under CentOS, super detailed!
MySQL 8.0 installation, deployment and configuration tutorial on CentOS 8
Centos7 installation and configuration of Jenkins
Centos6.5 installation and deployment of KVM
Installation under centos6.9 of jenkins learning
Java-JDK installation and configuration under CentOS
CentOs7 installation and deployment Zabbix3.4 original
Detailed explanation of Spark installation and configuration tutorial under centOS7
Centos8 minimal deployment and installation of OpenStack Ussuri detailed tutorial
CentOS 7 system installation and configuration graphic tutorial
Installation and use of Mysql under CentOS
Centos-6.5 installation and deployment of LNMP environment
Installation and configuration of redis under centos7
Centos7 installation and deployment of gitlab server
CentOS7 installation zabbix 4.0 tutorial (graphics and text)
KVM installation and preliminary use under CentOS 7.2
Centos7 installation and deployment of Airflow detailed
Redis3 installation under Centos7
Linux CentOS 7 installation tutorial
CentOS 6.5 system installation and configuration graphic tutorial (detailed graphic)
CentOS 7 installation and configuration graphic tutorials under VMware10
Installation and configuration of rsync server under CentOS 6.5
[CentOS environment deployment] Java7/Java8 deployment under CentOS
Installation and cracking of confluence6.3 operation records under Centos
Centos mysql installation and configuration
Redis cluster installation under CentOS
Centos7 installation and configuration prometheus
Installation and cracking of Jira7 operation records under Centos
CentOS 7 installation and configuration PPTP
Centos7.5 installation and configuration MongoDB4.0.4
Redis cluster installation under CentOS
CentOS 7 installation and configuration PPTP
Hyper-V + CentOS7 installation video tutorial
centos7 kvm installation and use
CentOS7 postgresql installation and use
Centos7.4 environment installation lamp-php7.0 tutorial
Centos7 elk7.1.1 installation and use
Install Mesos tutorial under CentOS7
Deployment of vulnerability scanning and analysis software Nessus under CentOS
Install and configure keepalived under CentOS 5.9
Centos iso image file installation tutorial
Use Nginx and u under CentOS
Centos7 installation of Dameng database tutorial
CentOS 8 installation of MariaDB detailed tutorial
RabbitMQ cluster deployment record under Centos6.9
CentOS6 minimal installation KVM detailed tutorial
Centos7 hadoop cluster installation and configuration
Elasticsearch cluster deployment record under CentOS7
Upgrade OpenSSL and OpenSSH under CentOS7
Deploy and optimize Tomcat under Centos
Centos8 installation diagram (super detailed tutorial)
Redis installation under ubuntu and windows
CentOS 7.X system installation and optimization
Install and use docker under CentOS 6.8
CentOS 7 Tomcat service installation and configuration
Ubuntu 16.04 installation graphic tutorial under VMware 12
CentOS NTP server installation and configuration