How can I install Jenkins Server on CentOS 7?. Jenkins is an open source automation server written in Java that was designed to automate repetitive tasks that are often encountered in continuous integration and delivery of software. Jenkins is typically run as a standalone application in its own process with the built-in Java servlet container/application server (Jetty).
Minimum Hardware requirements:
- 256 MB of RAM, 1 GB+ recommended
- 1 GB of drive space (although 10 GB is a recommended minimum if running Jenkins as a Docker container)
For Ubuntu, see: How to Install Jenkins on Ubuntu
For Arch Linux: How to Install and Configure Jenkins on Arch Linux
For Docker Container: Running Jenkins Server in Docker Container with Systemd
Step 1: Install Java OpenJDK on CentOS 7
Jenkins requires Java in order to run, but CentOS 7 doesn’t include it by default. To install the Open Java Development Kit (OpenJDK) run the following:
sudo yum -y install epel-release
sudo yum install java-11-openjdk
Check to make sure that you have java installed by running:
$ java -version
openjdk version "11.0.11" 2021-04-20 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.11+9-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.11+9-LTS, mixed mode, sharing)
Step 2: Install Jenkins Server on CentOS 7
Start by importing the repository key from Jenkins:
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
After importing the key, add the repository to the system:
sudo yum -y install wget
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
Then install Jenkins package using yum
:
sudo yum -y install jenkins
You can now start Jenkins service using:
$ sudo systemctl start jenkins
$ sudo systemctl enable jenkins
jenkins.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig jenkins on
A check on status should return running state
$ systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation Server
Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
Active: active (running) since Wed 2021-07-07 10:34:13 UTC; 4s ago
Docs: man:systemd-sysv-generator(8)
Process: 9205 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/jenkins.service
└─9232 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenki...
Jul 07 10:34:12 jenkins.example.com systemd[1]: Starting LSB: Jenkins Automation Server...
Jul 07 10:34:13 jenkins.example.com runuser[9210]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
Jul 07 10:34:13 jenkins.example.com jenkins[9205]: Starting Jenkins [ OK ]
Jul 07 10:34:13 jenkins.example.com systemd[1]: Started LSB: Jenkins Automation Server.
Enable port 8080/tcp
on the firewall:
sudo firewall-cmd --add-port=8080/tcp --permanent
sudo firewall-cmd --reload
sudo firewall-cmd --list-all
The service should be listening on port 8080
$ sudo ss -tunelp | grep 8080
tcp LISTEN 0 50 :::8080 :::*
Step 3: Unlock Jenkins on CentOS 7
Browse to the URL to access web installation wizard.
http://[serverip_or_hostname]:8080
When you first access a new Jenkins instance, you are asked to unlock it using an automatically generated password.
Get the password from
$ cat /var/lib/jenkins/secrets/initialAdminPassword
75a6155d70b7435c9b382197c823aa35
Copy-paste the automatically-generated alphanumeric password into the Administrator password field and click Continue.
Next is to create an admin user account used to manage the Jenkins server.
Select plugins to install in the next page.
Step 4: Configure Nginx and SSL (Optional)
It is recommended to access Jenkins Server behind a Proxy server secured with SSL certificate. Check below guide.
Configure Jenkins behind Nginx reverse proxy and Let’s Encrypt SSL
Step 5: Configure User Roles on Jenkins
By default, Jenkins user policy allows logged in users to access anything. This should not be the case and you need to set proper user policies. Check out our Jenkins policy and user management guide below.
How to Manage Users and Roles in Jenkins
Let other users Login with their credentials and assign them roles which define what they can do on Jenkins server.
Conclusion
Enjoy automating your jobs with Jenkins. For more reading, check Official Documentation. We will publish more articles on Jenkins and CI/CD.