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.
Prerequisites for this Tutorial:
- A Linux system with CentOS 8 Installed.
- A user account with sudo or root privileges.
- Access to a terminal window/command line.
- Java version 8.
Steps to Install Jenkins on CentOS 8
1. Install Java
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.
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 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:
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.
3. Install Jenkins on the system
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.
4. Start Jenkins Service
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
5. Configure 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.
6. 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:
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.
7. Create Users in Jenkins
- Firstly, go back to the Jenkins interface in the browser (http://ip-of-our-machine:8080) once our service is up and running.
- Then select Manage Jenkins from the left-hand menu.
- This will take us to a page with a variety of customization options.
- We might also notice a warning at the top: Jenkins is not secured, so anyone on the network can launch processes on our behalf. Consider enabling authentication at the very least to prevent abuse. Jenkins has given us instructions to add some level of security to our system.
- Then, near the top of the list of links on the manage Jenkins page, go to Configure Global Security.
- To bring up a group of options for this purpose, check the option box for Enable security.
- Then, select Jenkins own user database from the Access Control section that appeared after we flagged the checkbox.
- Deselect the Allow users to sign up checkbox. Only administrators will be able to create new accounts as a result of this.
- Then, select the Matrix-based security option under Authorization.
- We’ll see that there's already a user named Anonymous. An anonymous user can be anyone from anywhere, even if they aren’t logged in, which is why they have no abilities by default.
- Then, to select all permissions, click the small button to the right of the Anonymous row.
- Finally, use the User/group to add input field to specify a new user for whom we should add the permissions.
- Press Add after entering a username. As with the anonymous user, grant all permissions to the new user. In essence, this creates a new administrator.
- Then, Press Apply and then Save.
- We'll be automatically redirected to a signup page where we can create a new account.
- Then, Scroll down to the security matrix on the security page (Manage Jenkins -> Configure Global Security).
- Finally, we can restrict the permissions of the anonymous user now that we’ve created an administrative user. Click Apply and Save after deselecting all of the permissions in the anonymous row.
8. Create Additional users in Jenkins
- Firstly, Return to the Manage Jenkins page.
- Then, near the bottom of the page, click Manage Users.
- A sidebar with links will be found on the left. Select Create User from the drop-down menu.
- Then, in the same way that we created the first user, enter the information for the new user.
- After that, click Sign up.
- Then, we'll be taken to the user list, which will now include the new user.
- We’ll have to repeat the permissions process because this user will have no permissions.
- Go to Global Security Configuration.
- Then specify permissions using the User/group to add field to add a row to the matrix.
- Finally, click Save and Apply.
If we have multiple users to create, create them all before adding permissions for the sake of simplicity.
[Need help in fixing DigitalOcean Droplet Server issues ? We can help you. ]