In this Guide we are going to learn how to install and configure Jenkins in Rocky Linux/Centos 8. This will also work for other RHEL 8 derivatives like Alma Linux.
Jenkins is a popular opensource automation tool to perform continuous integration and build automation. Jenkins allows to execute a predefined list of steps, e.g. to compile golang source code to build build binary file. The trigger for this execution can be time or event based.
Possible steps executed by Jenkins are for example:
- Cloning the code from source control system.
- execute a command to install dependencies required for the code to run
- Run tests for the software
- build the software to get an executable
- Publish test results
- publish the resulting binary code
Jenkins monitors the execution of the steps and allows to stop the process, if one of the steps fails. Jenkins can also send out notifications in case of a build success or failure.
Jenkins can be extended by additional plug-ins. For example, you can install plug-ins to support building and testing Android applications.
Related Content
- How to install and set up Jenkins in Debian 11
- How to install and set up Jenkins in FreeBSD 13
- How to Install and set up Jenkins on Ubuntu 20.04
- How to install and set up Jenkins in Fedora 35
Requirements
- A Linux system with Rocky Linux/CentOS 8 server (At least 2GB of Ram)
- A user account with sudo or root privileges
- Access to a terminal window/command line
- Recent Java version installed
Ensuring that the system is up to date
Ensure that the system packages are up to date using this command:
|
|
Next, let us install common packages that we will need in our tutorial
|
|
Install Java
In this section, we will install java on our system. We will be using the openjdk version of java. In Rocky Linux 8, to check what software provides the java command line, use the following command to search dnf search jdk
. Since Jenkins uses Java version 11, we cann filter the result using grep.
|
|
We can see that it is jdk 11 is available as java-11-openjdk
. Install it using the command
|
|
Confirm the installed version using this command:
|
|
Install Jenkins
Add jenkins repository
Jenkins isn’t included in the default CentOS software repositories. Use the following commands to add and import the GPG key to ensure your software is legitimate.
|
|
Install jenkins
If its not yet installed, please use this command to install epel-release
. This repo contains some dependencies that our jenkins server needs like daemonize
.
|
|
Use the following command to install jenkins
|
|
Starting and enabling jenkins
Now that jenkins is installed, let us start it using this command:
|
|
To display the status of the Jenkins service, enter the following:
|
|
Please check to ensure that the status is active (running)
to know that the installation was successful.
To enable Jenkins on boot, use this:
|
|
Accessing the jenkins server
Once installed, open browser and navigate to the jenkins on the url http://127.0.0.1:8080/
. If you are running on a remote server, replace the ip 127.0.0.1
with that server’s ip.
You will be asked to provide an initial password found in this location /var/lib/jenkins/secrets/initialAdminPassword
. Get it by running this command on the server.
|
|
From here choose whether you want to install the recommended plugins or choose what you want to install.
The last page will allow you to set up some initial configuation for the user who will be using the jenkins server.
Optional- Using an Ansible playbook
You can use the following playbook to accomplish the same task. Save it to a file like install-jenkins.yaml
.
To run the playbook:
- Ensure ansible is installed. Checkout guide on how to install here.
- Create a hosts file with connection information
- Run the command
ansible-playbook -i <hosts-file-path> install-jenkins.yaml -vvv
|
|
Conclusion
We managed to install Jenkins in Rocky Linux server in this guide.