Install Jenkins on CentOS 8

Step 1: Install Java

Install Java 8 on your system. If you already have Java 8 installed and set as the default, skip ahead 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, then prompt you for confirmation.
Type y and press Enter. Allow the system to download and install Java.

Terminal output showing successful Java installation

Step 2: Add Jenkins Software Repository

Jenkins isn’t 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 reach out to the Jenkins server and download the location of the repository to your system. It should display /etc/yum.repos.d/jenkins.repo saved.

example of Adding Jenkins repository on CentOS 8

Adding the repository manually – In some instances, the repository will not download correctly. 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:

The Jenkins repo file after manually adding a repository in nano

Next, import the GPG key to ensure 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 error.

Note: You may have noticed that the repository lists Red Hat, but your system is CentOS. This is because CentOS is based on the Red Hat Linux architecture.

Step 3: Install Jenkins on CentOS 8

To Install Jenkins on CentOS 8,  enter the following in the terminal:

sudo dnf install jenkins
screenshot of the Terminal output of a Jenkins installation

If you receive an error that mentions “jenkins not found,” go back and add the repository manually as outlined in the previous step.

The system will prompt you to confirm the installation. Type y, press Enter, and let the installation complete.

Start Jenkins Service

To start the Jenkins service and enable it at startup, enter the following:

sudo systemctl start jenkins
sudo systemctl enable jenkins

To display the status of the Jenkins service, enter the following:

sudo systemctl status jenkins
CentOS terminal showing Jenkins status.

Step 4: Set Firewall to Allow Jenkins

The Jenkins service uses port 8080 to communicate. If you’re using the default firewalld service, enter the following commands to allow access:

sudo firewall-cmd ––permanent ––zone=public ––add-port=8080/tcp

sudo firewall-cmd ––reload

The system reports success for each command.

If you’re using a different firewall, follow its instructions to allow TCP traffic on port 8080.

Step 5: Run and Set up Jenkins on CentOS 8

Next, you’ll test your system to make sure Jenkins is working correctly. 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 that instead.

The browser should display an Unlock Jenkins page. It will ask you to enter a temporary password.

Jenkins unlock page in a browser

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 prompt you to install plugins. It is recommended that you Install suggested plugins. You can always change or customize plugins later.

Jenkins Customize page to install plugins.

Once plugins are configured, you’ll be prompted to Create First Admin User. Enter the values you want for your Jenkins Administrator, then click Save and Continue.

The last page will display the Instance Configuration. This shows the hostname Jenkins is configured for. This is usually the same hostname you typed into your browser to access the Getting Started page. If you do not create an admin user, there will be a warning.

Click Save and Finish, then Start using Jenkins.

The page showing Jenkins is ready to be started

This step takes you to the Jenkins dashboard where you can create new jobs.

Jenkins dashboard homepage where you can start new jobs.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Back To Top