CentOS

How to Install Jenkins on CentOS 8

How to Install Jenkins on CentOS 8

Jenkins is a popular and open-source automation program based on Java. It helps developers to efficiently manage their tasks like building, testing, and deploying software. It automates software builds in a systematic way and notifies developers of errors as early as possible. It is a feature-rich program that can be extended through various plugins.

In today’s post, we will be describing how to install Jenkins on CentOS. You will require root or sudo privileges for installing Jenkins on your CentOS machine.

Note: We have tested the procedure and commands described here on CentOS 8 machine.

Installing Jenkins on CentOS

Jenkins is not available in the CentOS default package repositories. We can install it by manually adding the Jenkins repository to our system repositories. Let’s get started.

1. Install Prerequisites

First, install prerequisites using the command below:

$ sudo yum install java-11-openjdk-devel

Enter sudo password and if it asks for confirmation, press y and then Enter to confirm. After that, prerequisites will be installed.

2. Add Jenkins Repository

Add the Jenkins repository to your system repositories using the below command:

$ sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo

This command will add Jenkins repository file jenkins.repo to the /etc/yum.repos.d directory.

3. Import Repository Key

Now import the Jenkins repository key so that the system can verify the package.

$ sudo rpm ––import https://pkg.jenkins.io/redhat/jenkins.io.key

4. Install Jenkins

Now in order to install Jenkins, use the command below:

$ sudo yum install jenkins

If it asks for confirmation, press y and then Enter to confirm. After that, Jenkins will be installed on your machine.

5. Start Jenkins

After Jenkins is installed, you will need to start and enable its service. To start Jenkins on your system, here is the command:

$ sudo systemctl start jenkins

To enable the service to start it automatically at boot, use the command below:

$ sudo systemctl enable jenkins

Then you can verify the status of service using the command below:

$ sudo systemctl status jenkins

If everything is working well, there will be active (running) status in the command output.

6. Adjust Firewall

Jenkins listens on port 8080. If your system is protected by a firewall and you want to access Jenkins from a remote machine, you will have to open port 8080 in your firewall.

First, to check if your system (where Jenkins is installed) is protected by a firewall, use the command below:

$ sudo systemctl status firewalld

If you see active (running) status in the output, it means the firewall is enabled on your system.

To open the port 8080 used by Jenkins in the firewall, use the command below:

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

Then reload firewall:

$ sudo firewall-cmd --reload

7. Post-installation Setup Wizard

Now open your web browser and access http:/ip_address:8080 where ip_address is the IP address of the system where Jenkins is installed.

It will open the following Unlock Jenkins page in your web browser which contains the location of the administrator password.

You will have to retrieve the password from this location. To do so, open the Terminal and type sudo cat followed by the location of the password mentioned in the Unlock Jenkins page. The command will output the Administrator password on the Terminal.

Copy the password and type it under the Administrator password bar, then click Continue.

Then on the next page, click Install suggested plugins or click Select plugins to install if you want to select the plugins manually.

Plugins will then be installed.

Then the following page will appear for you to create the first Administrative user. Provide the asked information and click Save and Continue or click Skip and continue as admin if you want to continue as admin. In the later case, you can use admin as the username and password that we used to access the setup wizard.

Next, on the Instance Configuration page, you will see the automatically generated URL of the Jenkins. Click Save and Finish.

Now the following page will appear showing how you to log in using the admin as username and password that you used to access the setup wizard. The post-installation wizard has been completed, click Start using Jenkins.

You will then see the below Dashboard. Now the Jenkins has been successfully installed and you can start using it.

Remove Jenkins from CentOS

In case you want to remove Jenkins from your system, use the command below to do so:

$ sudo yum remove Jenkins

Provide sudo password. If prompted for confirmation, press y. After which, it will remove Jenkins from your system.

In today’s post, we described how to install Jenkins on CentOS system. We also described how to manage Jenkins services, allow them in firewall, and access Jenkins using the web browser. In the end, we described how to uninstall Jenkins in case you need to do so. If you are working on Ubuntu OS, visit how to install Jenkins on Ubuntu.

Similar Posts