Introduction
Jenkins is an open source software package for continuous software development. It is used to automate parts of the build, test, delivery, and deployment of applications.
Jenkins is based on Java and helps with every part of the software development process.
This guide will show you how to install Jenkins on CentOS 8.
Prerequisites
A
- Linux system with CentOS 8 installed
- user account with sudo or root privileges
- Accessing a terminal/command line window
- Java version 8
A
A
brief note about Jenkins Jenkins
is a CI/CD software application. CI stands for Continuous Integration, which refers to the implementation of changes throughout the software development process. CD stands for Continuous Delivery, which refers to a continuous stream of updates for an application.
Jenkins requires Java to run. It will work with Java 8 or Java 11, but some plugins are not compatible with Java 11. This guide uses the open source Java JDK 8 environment. JDK stands for Java Developer Kit, and includes all the files needed to run Java applications.
Step 1: Install
Java
Install Java 8 on your system. If you already have Java 8 installed and set as default, skip to step 2.
Open a terminal window and enter the following:
sudo dnf install java-1.8.0-openjdk-devel
The system will scan the repositories and then ask for confirmation. Type y and press Enter. Allow the system to download and install Java.
Step 2: Add
Jenkins Software
Repository Jenkins is not included in the default CentOS software repositories. To add the Jenkins repository, open a terminal window and enter the following:
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
The system will communicate with the Jenkins server and download the repository location to your system. It should show /etc/yum.repos.d/jenkins.repo saved.
Add the repository
manually: In some cases, the repository will not download successfully. To manually add the repository, enter the following:
sudo nano /etc/yum.repos.d/jenkins.repo
This will open the jenkins.repo file for editing. Enter the following lines:
[jenkins] name=Jenkins-stable baseurl=http://pkg.jenkins.io/redhat gpgcheck=1
Save the file (ctrl-o) and exit (ctrl-x). The file should look like this
: Next, import the
GPG key to make sure your software is legitimate
: sudo rpm -import https://pkg.jenkins.io/redhat/jenkins.io.key If the
process is successful, the system returns a new command line without errors.
Step 3: Install Jenkins on CentOS 8
To install Jenkins on CentOS 8, enter the following in the terminal:
sudo dnf install jenkins
If you receive an error that mentions “jenkins not found”, go back and add the repository manually as described in the previous step.
You will be prompted to confirm the installation. Type , and press Enter and let the installation complete.
Start the Jenkins service To start the Jenkins service
and enable it at startup
, type the following: sudo systemctl start jenkins sudo systemctl enable jenkins
To display the status of the Jenkins service, type the following
: sudo systemctl status Jenkins
Step 4: Configure the firewall to allow
Jenkins The
Jenkins
Service It uses port 8080 to communicate. If you are using the default service with firewall, type the following commands to allow access
: sudo firewall-cmd -permanent -zone=public -add-port=8080/tcp sudo firewall-cmd -reload
The system reports that each command was successful
.
If you are using a different firewall, follow its instructions to allow TCP traffic on port 8080.
Step 5: Run and configure Jenkins on CentOS 8
Next, you will test your system to make sure that Jenkins is working properly. Open a web browser and enter the following URL:
http://localhost:8080
If your server is remote or has a specific hostname, domain name, or IP address, use it instead
.
Your browser should display an Unblock Jenkins page. It will ask you to enter a temporary password.
This password was created automatically (but not displayed) during setup. To find it, switch to a terminal window and enter the following:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
The location is displayed on the Getting Started / Unlock Jenkins page
.
The system will display an alphanumeric code. Copy this code and paste it into the password field. Then click Continue.
Jenkins will ask you to install plugins. It is recommended that you install the suggested add-ons. You can always change or customize add-ons later.
Once the add-ins are configured, you will be prompted to create the first admin user. Enter the values you want for your Jenkins administrator, and then click Save and Continue.
The last page will display the Instance Configuration. This displays the host name for which Jenkins is configured. Usually, this is the same hostname you typed in your browser to access the Getting Started page. If you do not create an administrator user, there will be a warning.
Click Save and finish to start using Jenkins.
This step takes you to the Jenkins dashboard, where you can create new jobs.
Conclusion
You should now have a working installation of Jenkins on your CentOS 8 system. If you followed the steps in this guide, your Jenkins dashboard should load correctly and you can start creating jobs.
If you are using a different Linux distribution, we also have a guide on how to install Jenkins od Debian 10 and how to install Jenkins on Ubuntu.