How to Install Jenkins on Rocky Linux 8

Jenkins is an open-source automation server that helps with the automation of testing and building. Its usage has grown very quickly in open source, and more than 6000 projects use it. Some examples of Jenkins users are:

  • Red Hat
  • Facebook
  • Google

As such, Jenkins can be run on almost any hardware or operating system, which allows its users to use their own infrastructure to set up a continuous integration server or even a continuous delivery environment.

This flexibility is one of the reasons why so many companies have adopted this software: they did not need to purchase an expensive solution from a third party, and they also didn’t need development expertise themselves, as most people who contribute to Jenkins’ development do it in their free time. In fact, there is no company behind Jenkins at all; this is the reason why it is an open-source project.

Jenkins has also seen its fair share of criticism, though. The most important point to address would be that Jenkins can actually cause more harm than good if used without thinking things through first. For example, one feature that many users love about it is how easy installing plugins for Jenkins is—there’s even a graphical user interface to do so!

But this also means that there are countless conflicting plugins available out there which can create problems when running multiple jobs on your server because each plugin has its own dependencies. The solution to this problem is actually quite simple though: just read the release notes of any plugins you are about to install and choose ones that have been recently updated for compatibility with your version of Jenkins.

Another issue people tend to forget is security. Again, because anyone can create a Jenkins plugin easily (let’s not even talk about what kind of code they might be writing), it will only take one misconfigured or maliciously created a plugin to put your server at risk; there used to be an exploit out there two years ago which could do it automatically using the update center feature alone.

But these are far from all the things that can go wrong if you’re not careful with Jenkins as it is. You should also safeguard yourself against people who might want to exploit your server for their own benefit and be aware that your security is only as good as the weakest link in it.

Perhaps the most important thing of all, though, would be to learn how to use Jenkins properly by reading about best practices and documentation instead of just installing plugins and hoping they work well with each other.

This guide will show you the installation steps for Jenkins Server on a Rocky Linux 8 system.

Prerequisites

In order to follow this guide, you will need:

  • A server with Internet access and an empty Hard Drive of at least 15 GB.
  • Root user access (password).

Updating the System

It’s a good idea to start this installation by updating our package repositories. You can do this by running the following commands.

sudo dnf check-update && sudo dnf update -y

Installing Java

Jenkins is written in Java, so you will need to install it on your system. Installing the JDK (Java Development Kit) is mandatory, it is highly recommended for development purposes. If you want to develop your own plugins or run tests on your build servers, having the JDK installed can be very useful.

In this guide, we will install JDK 11. JDK 11 is an open-source implementation of the Java SE 11 platform. It contains, among others: OpenJDK Runtime Environment (build 11+28), and compiler (build 11+28).

The JDK 11 package is included in the Rocky Appstream repository by default, you can run the following command to show all java packages available in your system.

sudo dnf search java-*-openjdk

You will get the following output.

Install OpenJDK

Run the following command to install JDK 11 on your system.

sudo dnf -y install java-11-openjdk

Once the installation process is finished you can run the command below to confirm that Java has been installed successfully.

java -version

You should get an output similar to the following.

Check Java version

Adding Jenkins Repository

The Jenkins package is not included in the Rocky Appstream repository by default. Luckily, the Jenkins developer team has made their own repository publicly available, so we can use it for our installation.

You can add the Jenkins repository using the following commands:

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

Now, run the command below to check if you have added the repository correctly.

sudo dnf repolist

You should get something like this

dns repolist

Installing Jenkins on Rocky Linux

Now that all prerequisites are installed, it is time to move on to the installation itself. Run the following command to install Jenkins.

sudo dnf -y install jenkins

Once the installation is finished run the following command to start the jenkins service.

sudo systemctl start jenkins

To start the jenkins service on boot, run the following command.

sudo systemctl enable jenkins

Now let’s check its status to make sure that everything is working properly.

sudo systemctl status jenkins.service

The output should be similar to this.

Jenkins service

Accessing and Configuring Jenkins

Now that your Jenkins server is running, you can access it from your browser. You can use the following URL for this purpose.

http://server_ip:8080

Where server_ip is the actual IP address of your server. For example, if your server’s IP is 192.168.1.3, you will use the following URL for access:

http://192.168.1.3:8080

You will get the following page if everything is working properly. You can see the /var/lib/jenkins/secrets/initialAdminPassword in clear text, which is the location of the user’s password used to access Jenkins.

This is a temporary password created during the installation but not shown. Now go back to your terminal and run the command below to get the password.

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

You should get something like this.

Jenkins admin password

Now, copy the password. Return to your browser and paste the password into the Administrator password field. Click on Continue.

Unlock jenkins

You will be taken to the Plugins page, as shown below. Plugins extend Jenkins by adding new functionality. The Jenkins server has a lot of plugins available out of the box to accomplish a wide variety of tasks.

For now, for a new installation, it’s recommended to go for the install suggested plugins option. You can always add more plugins at a later stage from the Jenkins dashboard.

Customize Jenkins

Once you click on the button, the plugin installation process will start. This may take a while.

Getting Started with Jenkins Automation Server

Once the plugin installation process is complete, you will be taken to the Admin User Setup page. Enter your admin user name and password, followed by clicking on Save and Continue button.

Create admin user

On the next Instance Configuration page, you will be able to configure the Jenkins URL. Keep the default and click Save and Finish.

Instance configuration

Finally, click on Start using Jenkins on the final page.

Jenkins is ready

You will be taken to the Jenkins dashboard, where you can explore the list of plugins, projects, and other functionalities that you can add.

Jenkins dashboard

Conclusion

You have successfully installed Jenkins on your Rocky Linux 8 Server. You can now start creating your own automation projects.

Please refer to the official documentation for more information on the installation of Jenkins on Rocky Linux 8, which can be found here. For any questions or concerns, feel free to comment below.