How to install and configure Jenkins on Rocky Linux 9.2

To Install Jenkins On Rocky Linux 9.2

Introduction:

Jenkins is an open-source automation server that automates the repetitive technical tasks involved in the continuous integration and delivery of software. Jenkins is Java-based, installed from Ubuntu packages or by downloading and running its web application archive (WAR) file — a collection of files that make up a complete web application to run on a server.

Installation Steps:

Step 1: Check the OS version by using the below command
[root@Linuxhelp ~]# cat /etc/os-release
NAME="Rocky Linux"
VERSION="9.2 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.2"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.2 (Blue Onyx)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
SUPPORT_END="2032-05-31"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"
ROCKY_SUPPORT_PRODUCT_VERSION="9.2"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.2"

Step 2: Jenkins is a Java-based application, so we need to install latest version of Java Development Kit (JDK) by running the below command

[root@Linuxhelp ~]# dnf install java-17-openjdk -y
Last metadata expiration check: 1:52:28 ago on Tuesday 07 November 2023 05:36:58 AM.
Dependencies resolved.
======================================================================================================================
 Package                              Architecture       Version                          Repository             Size
======================================================================================================================
Installing:
 java-17-openjdk                      x86_64             1:17.0.9.0.9-2.el9               appstream             432 k
Installing dependencies:
 copy-jdk-configs                     noarch             4.0-3.el9                        appstream              27 k
 java-17-openjdk-headless             x86_64             1:17.0.9.0.9-2.el9               appstream              45 M
 javapackages-filesystem              noarch             6.0.0-4.el9                      appstream              11 k
 lksctp-tools                         x86_64             1.0.19-2.el9                     baseos                 90 k
xorg-x11-fonts-Type1                 noarch             7.5-33.el9                       appstream             499 k
Transaction Summary
======================================================================================================================
Install  11 Packages

Total download size: 47 M
Installed size: 199 M
Downloading Packages:
(1/11): lksctp-tools-1.0.19-2.el9.x86_64.rpm                                          278 kB/s |  90 kB     00:00    
(2/11): copy-jdk-configs-4.0-3.el9.noarch.rpm                                         535 kB/s |  27 kB     00:00    
(3/11): javapackages-filesystem-6.0.0-4.el9.noarch.rpm                                 27 kB/s |  11 kB     00:00    
----------------------------------------------------------------------------------------------------------------------
Total                                                                                 8.5 MB/s |  47 MB     00:05     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Running scriptlet: copy-jdk-configs-4.0-3.el9.noarch                                                            1/1 
  Running scriptlet: java-17-openjdk-headless-1:17.0.9.0.9-2.el9.x86_64                                           1/1 
  Preparing        :                                                                                              1/1 
  Installing       : mkfontscale-1.2.1-3.el9.x86_64                                                              1/11 
  Installing       : ttmkfdir-3.0.9-65.el9.x86_64                                                                2/11 
  Installing       : xorg-x11-fonts-Type1-7.5-33.el9.noarch                                                      3/11 
Installed:
  copy-jdk-configs-4.0-3.el9.noarch                             java-17-openjdk-1:17.0.9.0.9-2.el9.x86_64            
  java-17-openjdk-headless-1:17.0.9.0.9-2.el9.x86_64            javapackages-filesystem-6.0.0-4.el9.noarch           
  lksctp-tools-1.0.19-2.el9.x86_64                              lua-5.4.4-3.el9.x86_64                               
  lua-posix-35.0-8.el9.x86_64                                   mkfontscale-1.2.1-3.el9.x86_64                       
  ttmkfdir-3.0.9-65.el9.x86_64                                  tzdata-java-2023c-1.el9.noarch                       
  xorg-x11-fonts-Type1-7.5-33.el9.noarch                       
Complete!

Step 3: Check the java version by using the below command

[root@Linuxhelp ~]# java --version
openjdk 17.0.9 2023-10-17 LTS
OpenJDK Runtime Environment (Red_Hat-17.0.9.0.9-1) (build 17.0.9+9-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-17.0.9.0.9-1) (build 17.0.9+9-LTS, mixed mode, sharing)

Step 4: To install Jenkins, we need to add the official Jenkins repository. Execute the beneath commands one after the another. These commands will download the Jenkins repository file and import the repository key.

[root@Linuxhelp ~]# wget -O /etc/yum.repos.d/jenkins.repo \
    https://pkg.jenkins.io/redhat-stable/jenkins.repo
--2023-11-07 07:34:39--  https://pkg.jenkins.io/redhat-stable/jenkins.repo
Resolving pkg.jenkins.io (pkg.jenkins.io)... 151.101.2.133, 151.101.66.133, 151.101.130.133, ...
Connecting to pkg.jenkins.io (pkg.jenkins.io)|151.101.2.133|: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      

2023-11-07 07:34:39 (498 KB/s) - ‘/etc/yum.repos.d/jenkins.repo’ saved [85/85]
[root@Linuxhelp ~]# rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key

Step 5: Now install the Jenkins by using the below command

[root@Linuxhelp ~]# dnf install jenkins -y
Jenkins-stable                                                                         65 kB/s |  27 kB     00:00    
Dependencies resolved.
======================================================================================================================
 Package                    Architecture              Version                        Repository                  Size
======================================================================================================================
Installing:
 jenkins                    noarch                    2.414.3-1.1                    jenkins                     85 M

Transaction Summary
======================================================================================================================
Install  1 Package

Total download size: 85 M
Installed size: 85 M
Downloading Packages:
jenkins-2.414.3-1.1.noarch.rpm                                                         10 MB/s |  85 MB     00:08    
----------------------------------------------------------------------------------------------------------------------
Total                                                                                  10 MB/s |  85 MB     00:08     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                              1/1 
  Running scriptlet: jenkins-2.414.3-1.1.noarch                                                                   1/1 
  Installing       : jenkins-2.414.3-1.1.noarch                                                                   1/1 
  Running scriptlet: jenkins-2.414.3-1.1.noarch                                                                   1/1 
  Verifying        : jenkins-2.414.3-1.1.noarch                                                                   1/1 

Installed:
  jenkins-2.414.3-1.1.noarch                                                                                          
Complete!

Step 6: Reload the Jenkins daemon by using the below command

[root@Linuxhelp ~]# systemctl daemon-reload

Step 7: Start and enable Jenkins service using below command

[root@Linuxhelp ~]# systemctl start jenkins
[root@Linuxhelp ~]# systemctl enable jenkins
Created symlink /etc/systemd/system/multi-user.target.wants/jenkins.service → /usr/lib/systemd/system/jenkins.service.

Step 8: Check the status of Jenkins service using below command

[root@Linuxhelp ~]# systemctl status jenkins
● jenkins.service - Jenkins Continuous Integration Server
     Loaded: loaded (/usr/lib/systemd/system/jenkins.service; enabled; preset: disabled)
     Active: active (running) since Tue 2023-11-07 07:38:27 IST; 58s ago
   Main PID: 82908 (java)
      Tasks: 48 (limit: 22877)
     Memory: 1.0G
        CPU: 1min 21.842s
     CGroup: /system.slice/jenkins.service
             └─82908 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jen>

Nov 07 07:37:48 Linuxhelp jenkins[82908]: 53cbc5e6649d4893958376f713bd48bb
Nov 07 07:37:48 Linuxhelp jenkins[82908]: This may also be found at: /var/lib/jenkins/secrets/initialAdminPassword
Nov 07 07:37:48 Linuxhelp jenkins[82908]: *************************************************************
Nov 07 07:38:27 Linuxhelp jenkins[82908]: 2023-11-07 02:08:27.252+0000 [id=32]        INFO        jenkins.InitReactor>
Nov 07 07:38:28 Linuxhelp jenkins[82908]: 2023-11-07 02:08:28.589+0000 [id=48]        INFO        hudson.util.Retrier>
lines 1-20/20 (END)

Step 9: Jenkins listens on port 8080 by default, now allow it through the firewall by using the below command

[root@Linuxhelp ~]# firewall-cmd --add-port=8080/tcp --permanent
Success

Step 10: Reload the firewalld to apply new changes by using the below command

[root@Linuxhelp ~]# firewall-cmd --reload
Success

Step 11: Now go to the browser and search with you IP or domain along with the port number as shown in the below image

You will see the above page

Step 12: Jenkins will create a password for the Admin user, to find that run the below command and then copy the same by using the below image

[root@Linuxhelp ~]# cat /var/lib/jenkins/secrets/initialAdminPassword
53cbc5e6649d4893958376f713bd48bb

Step 13: Enter the password and click continue button as shown in the below image Step 14: Now click the Install suggested plugins as shown in the below image Step 15: Jenkins plugin installation will now begin. All of those plugins will now be installed on your Jenkins as shown in the below image Step 16: After the installation completed then set up the administrator user for Jenkins. Input details, user, email, and password for your Jenkins, and click Save and continue as shown in the below image Step 17: Now enter the Jenkins URL that mentioned below

http://192.168.6.130:8080/ Step 18: Click 'Save and Finish' to complete Jenkins's initial configuration as shown in the below image Step 19: Click on Start using Jenkins, this will take us to Jenkins Dashboard

Conclusion :

We have reached the end of this article. In this guide, we have walked you through the steps required to install Jenkins on Rocky Linux 9.2. Your feedback is much welcome.

FAQ
Q
Do I need to install Java before Jenkins on Linux?
A
Yes, Jenkins is a Java-based application, so you need to have Java installed on your Linux system. Ensure you have Java (JRE or JDK) version 8 or higher before installing Jenkins.
Q
Why use the Jenkins pipeline?
A
Jenkins pipeline allows us to define a complete list of events that happen in the code lifecycle.
Q
Can I change the default port that Jenkins runs on?
A
Yes, you can change the port by editing the Jenkins configuration file located at /etc/sysconfig/jenkins. Look for the JENKINS_PORT variable and modify it to the desired port number.
Q
What is CI and CD in Jenkins?
A
Jenkins is used to implement Continuous Integration (CI) and Continuous Delivery (CD) for any development project. CI/CD, a key component of a DevOps strategy, allows you to shorten the development lifecycle while maintaining quality by automating tasks like testing.
Q
What is Jenkins?
A
Jenkins is an open-source automation server that is used for building, deploying, and automating software development processes. It helps in continuous integration and continuous delivery (CI/CD) pipelines.