How to install Jenkins on RHEL 8 / CentOS 8

Jenkins is a widely-used open-source automation server that can be used to automate tasks from building to deploying software. It’s pipelines are easy to understand, and you can simply add tasks the same way you would execute them on the command line.

In this tutorial we will install Jenkins on RHEL 8 / CentOS 8, we’ll run the server by hand from the command line, install it as a standard service, and deploy it into an Apache Tomcat container.

In this tutorial you will learn:

  • How to run Jenkins by hand
  • How to install Jenkins as a service
  • How to deploy Jenkins into an Apache Tomcat container
  • How to unlock Jenkins
  • How to open the port on the firewall Jenkins is serving on

The unlock page of Jenkins on first startup installation on RHEL 8 / CentOS 8

The unlock page of Jenkins on first startup installation on RHEL 8 / CentOS 8

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System RHEL 8 / CentOS 8
Software Jenkins 2.150.1
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to install jenkins on RHEL 8 / CentOS 8 step by step instructions



From the installation perspective, Jenkins is the ease of mind. A pure Java application that can run on anything that runs Java, also having an embedded Jetty server that removes the need for any container or other running environment for it to be functional. One can pick from the three ways to run Jenkins described below, the functionality and management will be the same.

  1. The first step is to acquire the software. That is only a wget away, as Jenkins is neatly packaged into a war file that can run on it’s own. Let’s download the archive:
    $ wget mirrors.jenkins.io/war-stable/latest/jenkins.war
  2. There is no installation needed (apart from unlocking, described later), we can simply start the server in standalone mode from the command line:
    java -jar jenkins.war

    A lengthy output will be presented, as well as the password for the unlock step. After a bit of work, the startup process should finish, and the below line presented in the output:

    INFO [Jenkins initialization thread] hudson.WebAppMain$3.run Jenkins is fully up and running

    After this line appeared we can point our browser to the machine’s 8080 port, and the unlock page greets us (if the firewall port is opened, explained later). To stop the server simply press CTRL+C.

  3. To install Jenkins as a standard service, we need to import the Jenkins repository’s key:
    # rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key

    And we need to add the Jenkins repository to our system’s repositories:



    # wget http://pkg.jenkins-ci.org/redhat/jenkins.repo -O /etc/yum.repos.d/jenkins.repo

    After this we can install Jenkins with dnf:

    # dnf install jenkins

    This way we get all the nice extras of a service, we can start, stop, and get the status of Jenkins with systemd:

    systemctl start|stop|status jenkins

    As with the previous step, pointing a browser to the machine’s 8080 port where now Jenkins is running will result in the unlock page. The password will be in /var/log/jenkins/jenkins.log.

  4. If we already have a running Apache Tomcat installation, we can deploy Jenkins into it. We need to download the war explained in step 1, then copy/move into the webapps directory of Tomcat:
    # cp /tmp/jenkins.war /opt/tomcat/webapps/

    Don’t forget to set the user running Tomcat as owner of the file:

    # chown tomcat:tomcat /opt/tomcat/webapps/jenkins.war

    If Tomcat is running and set to autodeploy, Jenkins will be deployed sortly, and will be reachable with a browser on http://<machine-name-or-ip-address>:8080/jenkins. The password needed to unlock Jenkins will be in /var/log/tomcat/catalina.out in this case.

  5. To unlock Jenkins, we need to enter the initial password generated which is in the output of java -jar jenkins.war, or in one of the logfiles described in the previous steps. After unlocking we can start using the server.
  6. If there is a firewall running, we need to open the port 8080 on it (if Jenkins is deployed into Tomcat, this step should be done already). To do so, we can use the predefined service of firewalld:
    firewall-cmd --permanent --zone=public --add-service=jenkins

    We need to reload the firewall:

    firewall-cmd --reload