Jenkins is an open-source software package for continuous software development. It is used to automate parts of the build, testing, delivery, and deployment of applications. Also it is based on Java and helps with every part of the software development process. Jenkins is a CI/CD software application. CI stands for Continuous Integration, which refers to implementing changes throughout the software development process. CD stands for Continuous Delivery, which refers to a continuous stream of updates for an application.
Here at Ibmi Media, we shall look into how to install Jenkins on CentOS 8 in DigitalOcean Droplet.
If you already have Java 8 installed and set as the default, skip ahead to the next step.
To begin, from your terminal, run the below command:
$ 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.
Jenkins isn't included in the default CentOS software repositories. To add the Jenkins repository, open a terminal window, and run the below command:
$ 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.
To add the repository manually in cases where the repository will not download correctly, you can run the below command to manually add the repository:
$ 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).
Next, import the GPG key to ensure your software is legitimate with the below command:
$ 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.
Run the below command to install Jenkins on CentOS 8:
$ sudo dnf install jenkins
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.
Now to start the Jenkins service and enable it at startup with the below command:
$ sudo systemctl start jenkins
$ sudo systemctl enable jenkins
To display the status of the Jenkins service, run the below command:
$ sudo systemctl status jenkins
You will see the "active (running)" status
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.
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.
This password was created automatically (but not displayed) during setup. To find it, switch to a terminal window and enter the following command:
$ 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.
If we have multiple users to create, create them all before adding permissions for the sake of simplicity.
This article covers how to set up Jenkins in Digitalocean using Centos 8. In fact, When automating tasks with Jenkins, users can optimize their workflow by quickly automating the jobs that servers cannot do themselves.