This article will guide you through the process of installing Jenkins on CentOS 8 / RHEL 8 server. Jenkins is an open source tool written in Java for automation and faster deployments. Jenkins is feature-rich and is vastly extendable through plugins.
After Jenkins installation, a guide on setting up Nginx as a reverse proxy to Jenkins server will be shared. We assume you have a ready RHEL / CentOS 8 server before you proceed. The process is identical to setup on RHEL / CentOS 7 system.
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)
Step 1: Install Java on RHEL / CentOS 8
Since Jenkins is written in Java, you need Java runtime environment setup on RHEL / CentOS 8.
sudo yum -y install java-11-openjdk-devel
Check Java version.
$ java -version openjdk version "11-ea" 2018-09-25 OpenJDK Runtime Environment (build 11-ea+28) OpenJDK 64-Bit Server VM (build 11-ea+28, mixed mode, sharing)
Set Java environment.
sudo vi /etc/profile.d/java.sh
export JAVA_HOME=$(dirname $(dirname $(readlink $(readlink $(which javac))))) export PATH=$PATH:$JAVA_HOME/bin export JRE_HOME=/usr/lib/jvm/jre export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
Source the file to start using it without logging out.
echo $JAVA_HOME env
Step 2: Add Jenkins RPM repository
Start by importing the repository key from Jenkins
sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.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 http://pkg.jenkins-ci.org/redhat/jenkins.repo
Step 3: Install Jenkins on RHEL 8 / CentOS 8
Then install Jenkins package using
sudo yum -y install jenkins
If you need the LTS release only, run the following commands instead:
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key sudo yum -y install jenkins
After installation, start and enable Jenkins service using:
sudo systemctl start jenkins sudo systemctl enable jenkins
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; generated) Active: active (running) since Mon 2019-04-15 00:32:01 EAT; 3min 26s ago Docs: man:systemd-sysv-generator(8) Tasks: 44 (limit: 11512) Memory: 713.8M CGroup: /system.slice/jenkins.service └─10841 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib> Apr 15 00:32:01 rhel8.localhost systemd: Starting LSB: Jenkins Automation Server… Apr 15 00:32:01 rhel8.localhost runuser: pam_unix(runuser:session): session opened for user jenkins by (uid=0) Apr 15 00:32:01 rhel8.localhost runuser: pam_unix(runuser:session): session closed for user jenkins Apr 15 00:32:01 rhel8.localhost systemd: Started LSB: Jenkins Automation Server.
Allow port 8080/tcp on the firewall.
sudo firewall-cmd --add-port=8080/tcp --permanent sudo firewall-cmd --reload sudo firewall-cmd --list-all
Step 4: Configure Jenkins on RHEL / CentOS 8
Browse to the URL http://[serverip|hostname]:8080 to access web installation wizard.
When you first access a new Jenkins instance, you are asked to unlock it using an automatically generated password.
# cat /var/lib/jenkins/secrets/initialAdminPassword 5e29f788df7748d2b5b3a62304aa0bc9
Copy-paste the automatically-generated alphanumeric password into the Administrator password field and click Continue.
Select Plugins to Install
Next is to create an admin user account used to manage the Jenkins server.
Step 5: 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 4: 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.
Congratulations!!. You have successfully installed Jenkins on RHEL / CentOS 8. For more reading, check Official Documentation. We will be publishing more articles on Jenkins and CI/CD. Stay connected,