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.
- 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
- 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
Table of content
- Ensuring that the system is up to date
- Install Java
- Install Jenkins
- Starting and enabling jenkins
- Accessing Jenkins
- Optional – Using an Ansible playbook
1. Ensuring that the system is up to date
Ensure that the system packages are up to date using this command:
sudo dnf -y update
Next, let us install common packages that we will need in our tutorial
sudo dnf install -y curl vim wget
2. 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.
# dnf search jdk | grep 11 Last metadata expiration check: 0:03:42 ago on Wed 24 Nov 2021 06:10:29 AM EAT. java-11-openjdk.x86_64 : OpenJDK 11 Runtime Environment java-11-openjdk-demo.x86_64 : OpenJDK 11 Demos java-11-openjdk-devel.x86_64 : OpenJDK 11 Development Environment java-11-openjdk-headless.x86_64 : OpenJDK 11 Headless Runtime Environment java-11-openjdk-javadoc.x86_64 : OpenJDK 11 API documentation java-11-openjdk-javadoc-zip.x86_64 : OpenJDK 11 API documentation compressed in a single archive java-11-openjdk-jmods.x86_64 : JMods for OpenJDK 11 java-11-openjdk-src.x86_64 : OpenJDK 11 Source Bundle java-11-openjdk-static-libs.x86_64 : OpenJDK 11 libraries for static linking
We can see that it is jdk 11 is available as
java-11-openjdk. Install it using the command
sudo dnf install -y java-11-openjdk
Confirm the installed version using this command:
$ java -version openjdk version "11.0.13" 2021-10-19 LTS OpenJDK Runtime Environment 18.9 (build 11.0.13+8-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.13+8-LTS, mixed mode, sharing)
3. 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.
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
If its not yet installed, please use this command to install
epel-release. This repo contains some dependencies that our jenkins server needs like
sudo dnf install epel-release
Use the following command to install jenkins
sudo dnf install jenkins
4. Starting and enabling jenkins
Now that jenkins is installed, let us start it using this command:
sudo systemctl start jenkins
To display the status of the Jenkins service, enter the following:
$ sudo systemctl status jenkins ● jenkins.service - LSB: Jenkins Automation Server Loaded: loaded (/etc/rc.d/init.d/jenkins; generated) Active: active (running) since Wed 2021-11-24 06:23:59 EAT; 4s ago Docs: man:systemd-sysv-generator(8) Process: 64639 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS) Tasks: 37 (limit: 23168) Memory: 241.4M CGroup: /system.slice/jenkins.service └─64645 /etc/alternatives/java -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -> Nov 24 06:23:59 cloudsrv.citizix.com systemd: Starting LSB: Jenkins Automation Server... Nov 24 06:23:59 cloudsrv.citizix.com jenkins: Starting Jenkins [ OK ] Nov 24 06:23:59 cloudsrv.citizix.com systemd: Started LSB: Jenkins Automation Server.
Please check to ensure that the status is
active (running) to know that the installation was successful.
To enable Jenkins on boot, use this:
sudo systemctl enable jenkins
5. 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.
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
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.
6. Optional – Using an Ansible playbook
You can use the following playbook to accomplish the same task. Save it to a file like
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
- name: Install jenkins on centos 8 hosts: jenkins-srv become: yes gather_facts: False tasks: - name: Install required packages dnf: name: - wget state: latest - name: Install java dnf: name: java-1.8.0-openjdk-1:22.214.171.1245.b01-1.el8_3.x86_64 state: latest - name: Add jenkins repository shell: | wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key args: warn: no - name: Install jenkins dnf: name: jenkins state: latest - name: Start jenkins service systemd: name: jenkins state: started - name: Enable jenkins service systemd: name: jenkins enabled: yes
We managed to install Jenkins in Rocky Linux server in this guide.
Pingback: How to install and set up Jenkins in Fedora 35
Pingback: How to install and set up Jenkins in Debian 11 – Citizix
Pingback: How to install and Configure Jenkins in Ubuntu 20.04
Pingback: How to install and Configure Jenkins in Opensus Leap 15
Pingback: How to install and set up Jenkins in Rocky Linux/Alma Linux 9