How to Install Jenkins on CentOS 8
3 min read
Jenkins is the most popular open-source, Java-based automation server that allows you to easily set up a continuous integration and continuous delivery (CI/CD) pipeline.
Continuous integration (CI) is a DevOps practice in which team members regularly commit their code changes to the version control repository, after which automated builds and tests are run. Continuous delivery (CD) is a series of practices where code changes are automatically built, tested, and deployed to production.
This tutorial covers the steps to install Jenkins on CentOS 8 from the official Jenkins repository.
Perform the following steps as root or user with sudo privileges to install Jenkins on CentOS 8:
Jenkins is written in Java, so the first step is to install Java. Jenkins requires Java versions 8 and 11, but some Jenkins plugins may not be compilable with Java 8.
We'll install OpenJDK 8:
sudo dnf install java-1.8.0-openjdk-devel
If you have multiple versions of Java installed on your system, make sure Java 8 is the default Java version.
The next step is to enable the Jenkins repository. Run the following commands to download the repo file and import the GPG key:
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
Install the latest stable version of Jenkins by typing:
sudo yum install jenkins
Once the installation process is complete, start the Jenkins service and enable it to start on system boot:
sudo systemctl start jenkins
sudo systemctl enable jenkins
To check whether Jenkins is running, type:
systemctl status jenkins
The output should look something like this:
Loaded: loaded (/etc/rc.d/init.d/jenkins; generated) Active: active (running) since Thu 2019-10-31 21:31:36 UTC; 3s ago ...
Adjusting the Firewall
If you are installing Jenkins on a remote CentOS server that is protected by a firewall, you need to port
Use the following commands to open the necessary port:
sudo firewall-cmd --permanent --zone=public --add-port=8080/tcp
sudo firewall-cmd --reload
Setting Up Jenkins
To start the Jenkins setup process, open your browser and type the domain or server's IP address followed by port
A screen similar to the following will appear, prompting you to enter the Administrator password that is created during the installation:
cat to display the password on the terminal:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
You should see a 32-character long alphanumeric password, as shown below:
Copy the password from the terminal, paste it into the “Administrator password” field and click “Continue”.
On the next screen, you will be asked whether you want to install the suggested plugins or to select the plugins to install. Click on the “Install suggested plugins” box and the installation process will start.
Once the installation is complete, you will be prompted to set up the first administrative user. Fill out all required information and click “Save and Continue”.
On the next page, the installer will ask you to set the URL for the Jenkins instance. The URL field will be populated with an automatically generated URL.
To complete the setup, confirm the URL by clicking on the “Save and Finish” button.
Finally, click on the “Start using Jenkins” button, and you will be redirected to the Jenkins dashboard logged in as the admin user you have created in one of the previous steps.
If you've reached this point, you've successfully installed Jenkins on your CentOS system.
In this tutorial, we have shown you how to install and complete the initial configuration of Jenkins on CentOS/RHEL based systems.
You can now visit the official Jenkins documentation page and start exploring Jenkins's workflow and plug-in model.
If you have any questions, please leave a comment below.