Jenkins on RHEL 9

Login to the node in root and perform the following steps.

Its always better to use the dnf than yum.

dnf is the recommended package manager for Red Hat-based distributions because it offers improved performance, dependency handling, user experience, and compatibility with modern software management practices. While you might still encounter yum on older systems or in legacy documentation, it's advisable to use dnf for package management on newer distributions.

sudo dnf update -y

In order to run Jenkins, we need to have Java installed on the node.

Install Temurin JDK

cat <<EOF > /etc/yum.repos.d/adoptium.repo
[Adoptium]
name=Adoptium
baseurl=https://packages.adoptium.net/artifactory/rpm/${DISTRIBUTION_NAME:-$(. /etc/os-release; echo $ID)}/\$releasever/\$basearch
enabled=1
gpgcheck=1
gpgkey=https://packages.adoptium.net/artifactory/api/gpg/key/public
EOF

Install Temurin 11

dnf -y install temurin-11-jdk

Install Jenkins

Lets add the Jenkins RPM repository!

  • Create RPM repository

    •     wget -O /etc/yum.repos.d/jenkins.repo <https://pkg.jenkins.io/redhat-stable/jenkins.repo>
      
  • Add repository key

    •     rpm --import <https://pkg.jenkins.io/redhat-stable/jenkins.io.key>
      
  • Add repository key

    •         rpm --import <https://pkg.jenkins.io/redhat-stable/jenkins.io.key>
      
  • Install Jenkins

    •        dnf -y install jenkins
      

Configure Jenkins

systemctl --full status jenkins
systemctl edit jenkins
  • lets add the service with the timezone

  •     [Service]
        Environment="JAVA_OPTS=-Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Djava.io.tmpdir=/var/cache/jenkins/tmp/ -Dorg.apache.commons.jelly.tags.fmt.timeZone=Asia/Kolkata -Duser.timezone=Asia/Kolkata"
        Environment="JENKINS_OPTS=--pluginroot=/var/cache/jenkins/plugins"
    
  • lets create a tmp directory so that all the created tmp directories will reside here rather than having a pile of everything at one place

  •     mkdir -p /var/cache/jenkins/tmp`
        chown -R jenkins:jenkins /var/cache/jenkins/tmp`
    
  • check if Jenkins is running or not

  •         systemctl show jenkins
    
  • check the service

  •         systemctl show jenkins
    
  • verify and start the Jenkins

  •         systemd-analyze verify jenkins.service
            systemctl start jenkins
            systemctl --full status jenkins
    
  • Check the auto-generated admin password

  •         journalctl -u jenkins
    
  • and add the jenkins service

  •         systemctl enable jenkins
    
  • lets make sure that the firewall does not stop us from viewing the jenkins dashboard

  •     sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent
        sudo firewall-cmd --zone=public --add-port=8443/tcp --permanent
        sudo firewall-cmd --reload
    
  • and if you are using cloud services make sure to add an inbound NSG rule for 8080