(Last Updated On: November 1, 2018)

This is a short blog post on the installation of Jenkins Server on CentOS 7. Jenkins is an open source automation server written in Java that was designed to automate repetitive tasks that are often encountered in continuous integration and delivery of software.

For Ubuntu, see: How to Install Jenkins on Ubuntu 18.04

For Arch Linux: How to Install and Configure Jenkins on Arch Linux

For Docker Container: Running Jenkins Server in Docker Container with Systemd

Minimum Hardware requirements:

  • 256 MB of RAM, 1 GB+ recommended
  • GB of drive space (although 10 GB is a recommended minimum if running Jenkins as a Docker container)

Install Jenkins on CentOS 7

Jenkins requires Java in order to run, but CentOS 7 doesn’t include it by default. To install the Open Java Development Kit (OpenJDK) run the following:

sudo yum -y install epel-release
sudo yum install java-1.8.0-openjdk

Check to make sure that you have java installed by running:

$ java -version
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

Start by importing the repository key from Jenkins

sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key

After importing the key, add the repository to the system

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

Then install Jenkins package using yum:

sudo yum install jenkins

If you need the LTS release only, run the following commands instead:

sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
sudo yum install jenkins

You can now start Jenkins service using:

sudo systemctl start jenkins

A check on status should return running state

$ sudo systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation Server
   Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
   Active: active (running) since Thu 2018-10-25 12:25:55 EAT; 4s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 2487 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/jenkins.service
           └─2508 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/j...

Oct 25 12:25:54 jenkins.example.com systemd[1]: Starting LSB: Jenkins Automation Server...
Oct 25 12:25:54 jenkins.example.com runuser[2492]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
Oct 25 12:25:55 jenkins.example.com jenkins[2487]: Starting Jenkins [  OK  ]
Oct 25 12:25:55 jenkins.example.com systemd[1]: Started LSB: Jenkins Automation Server.

Enable port 8080/tcp on the firewall

sudo firewall-cmd --add-port=8080/tcp --permanent
sudo firewall-cmd --reload
sudo firewall-cmd --list-all

The service should be listening on port 8080

# ss -tunelp | grep 8080
tcp    LISTEN     0      50       :::8080                 :::*                   users:(("java",pid=2508,fd=163)) uid:994 ino:1661983 sk:ffff91ce2a84a100 v6only:0 <->

Unlocking Jenkins

Browse to the URL http://[serverip|hostname]:8080 to access web installation wizard.

When you first access a new Jenkins instance, you are asked to unlock it using an automaticallygenerated password.

Get the password from

$ cat /var/lib/jenkins/secrets/initialAdminPassword

Copy-paste the automatically-generated alphanumeric password into the Administrator password field and click Continue.

In the next page, install recommended plugins or plugins that suit your desired Jenkins usage. if not sure, select installation of recommended plugins.

Next is to create an admin user account used to manage the Jenkins server.

After a successful installation, you’ll get to Jenkins Management console.

Enjoy automating your jobs with Jenkins. For more reading, check Official Documentation.