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
Software Requirements and Conventions Used
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
Subscribe to RSS and NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.
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.
- The first step is to acquire the software. That is only a
wget
away, as Jenkins is neatly packaged into awar
file that can run on it's own. Let's download the archive:$ wget mirrors.jenkins.io/war-stable/latest/jenkins.war
- There is no installation needed (apart from unlocking, described later), we can simply start the server in standalone mode from the command line:
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:java -jar jenkins.war
After this line appeared we can point our browser to the machine'sINFO [Jenkins initialization thread] hudson.WebAppMain.run Jenkins is fully up and running
8080
port, and the unlock page greets us (if the firewall port is opened, explained later). To stop the server simply press CTRL+C. - To install Jenkins as a standard service, we need to import the Jenkins repository's key:
And we need to add the Jenkins repository to our system's repositories:# rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
After this we can install Jenkins with# wget http://pkg.jenkins-ci.org/redhat/jenkins.repo -O /etc/yum.repos.d/jenkins.repo
dnf
:
This way we get all the nice extras of a service, we can start, stop, and get the status of Jenkins with# dnf install jenkins
systemd
:
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 insystemctl start|stop|status jenkins
/var/log/jenkins/jenkins.log
. - If we already have a running Apache Tomcat installation, we can deploy Jenkins into it. We need to download the
war
explained instep 1
, then copy/move into thewebapps
directory of Tomcat:
Don't forget to set the user running Tomcat as owner of the file:# cp /tmp/jenkins.war /opt/tomcat/webapps/
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# chown tomcat:tomcat /opt/tomcat/webapps/jenkins.war
/var/log/tomcat/catalina.out
in this case. - 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. - 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 offirewalld
:
We need to reload the firewall:firewall-cmd --permanent --zone=public --add-service=jenkins
firewall-cmd --reload