In this article, you’ll come to know how to install Jenkins on Rocky Linux 8 or CentOS 8. Jenkins is a very popular continuous integration and continuous delivery (CI/CD) tool used for development, deployment, and automation.
Steps to Install Jenkins on Rocky Linux 8 or CentOS 8
Step 1: Install OpenJDK 11 on Rocky Linux 8
sudo dnf -y install java-11-openjdk
Verify Java Version
$ java -version
Sample Output:
[sysadminxpert@Jenkins ~]$ java -version openjdk version "11.0.15" 2022-04-19 LTS OpenJDK Runtime Environment 18.9 (build 11.0.15+10-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.15+10-LTS, mixed mode, sharing) [sysadminxpert@Jenkins ~]$
Step 2: Add Jenkins YUM repository to Rocky Linux
sudo dnf -y install wget
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
Sample Output:
[sysadminxpert@Jenkins ~]$ sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo --2022-08-09 03:47:55-- https://pkg.jenkins.io/redhat-stable/jenkins.repo Resolving pkg.jenkins.io (pkg.jenkins.io)... 2a04:4e42:24::645, 151.101.154.133 Connecting to pkg.jenkins.io (pkg.jenkins.io)|2a04:4e42:24::645|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 85 Saving to: ‘/etc/yum.repos.d/jenkins.repo’ /etc/yum.repos.d/jenkins.repo 100%[=================================================================>] 85 --.-KB/s in 0s 2022-08-09 03:48:00 (5.16 MB/s) - ‘/etc/yum.repos.d/jenkins.repo’ saved [85/85] [sysadminxpert@Jenkins ~]$
Import GPG key
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
you can also download the Jenkins package.
check if the repository is now available
$ sudo dnf repolist
Sample output:
[sysadminxpert@Jenkins ~]$ sudo dnf repolist repo id repo name appstream Rocky Linux 8 - AppStream baseos Rocky Linux 8 - BaseOS extras Rocky Linux 8 - Extras jenkins Jenkins-stable powertools Rocky Linux 8 - PowerTools [sysadminxpert@Jenkins ~]$
Step 3: Install Jenkins on Rocky Linux 8
sudo dnf install jenkins
Type Y, then press the ENTER KEY to proceed with Jenkins installation on Rocky Linux.
Enable Jenkins service on Rocky Linux 8
sudo systemctl enable jenkins
Sample output
[sysadminxpert@Jenkins ~]$ sudo systemctl enable jenkins Synchronizing state of jenkins.service with SysV service script with /usr/lib/systemd/systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-install enable jenkins [sysadminxpert@Jenkins ~]$
Start Jenkins service on Rocky Linux 8
sudo systemctl start jenkins
Verify Jenkins service status
$ systemctl status jenkins
Step 4: Configure the firewall and allow 8080 port
sudo firewall-cmd --permanent --zone=public --add-port=8080/tcp sudo firewall-cmd --reload
Step 5: Configure Jenkins on Rocky Linux 8
To configure Jenkins you need to access it on any web browser with a domain/host IP address.
http://your_server_ip:8080 (or) http://domain:8080 (or) http://hostname:8080
5.1: Unlock Jenkins
When you access Jenkins for the first time (after installation) it will ask you for the password. And to know the password run the below command, and you will see a 32-character alphanumeric password.
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Copy the password and paste it into the Jenkins Administrator section.
5.2: Customize Jenkins
On the Next page, Jenkins will ask you to choose/install the suggested plugins or the select most suitable/specific plugins.
For this blog, I choose suggested plugins to continue the plugin’s installation process.
5.3: Getting Started
Create the Jenkins first admin user. Fill in the details, and click on ‘save and continue’.
5.4: Instance Configuration
You will get the Jenkins URL with the port. Click on ‘save and finish‘.
The next step is to click on ‘start using Jenkins’.
5.5: Jenkins Dashboard
It will redirect to the Jenkins dashboard.
Troubleshooting If Jenkins is not started.
– Update ownership of Jenkins directories:
sudo chown -R jenkins:jenkins /var/log/jenkins sudo chown -R jenkins:jenkins /var/lib/jenkins sudo chown -R jenkins:jenkins /var/cache/jenkins sudo systemctl daemon-reload
– Install devel package
yum install java-11-openjdk-devel
– Adding Jenkins user to root group (Optional)
usermod -a -G root jenkins
End of article. We’ve explained how to install Jenkins on Rocky Linux 8 or CentOS 8.
See also:
How is AI Accelerating DevOps in 2022