In this Guide we are going to learn how to install and configure Jenkins in a Debian 11 Server.
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 Rocky Linux/Centos 8
- 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
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 apt update
sudo apt -y upgrade
Next, let us install common packages that we will need in our tutorial
sudo apt install -y curl vim wget
2. Install Java
Jenkins requires Java 11 to run. Ensure that Java is installed in the right version before proceeding. If you get the error below, then we need to install java.
$ java -version
-bash: java: command not found
We will install the openjdk version of Java using the command below. You can always search using this command apt-cache search openjdk | grep 11
:
sudo apt install -y openjdk-11-jdk
Confirm that the right version was installed
$ java -version
openjdk version "11.0.13" 2021-10-19
OpenJDK Runtime Environment (build 11.0.13+8-post-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 11.0.13+8-post-Debian-1deb11u1, mixed mode, sharing)
3. Install Jenkins
This is the Debian package repository of Jenkins to automate installation and upgrade. To use this repository, first add the key to your system:
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
Then add a Jenkins apt repository entry:
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
Update your local package index, then finally install Jenkins:
sudo apt-get update sudo apt-get install jenkins
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[1]: Starting LSB: Jenkins Automation Server...
Nov 24 06:23:59 cloudsrv.citizix.com jenkins[64639]: Starting Jenkins [ OK ]
Nov 24 06:23:59 cloudsrv.citizix.com systemd[1]: 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.
After that Ensure the correct URL is set in the last page of the instance configuration page. After this you will be redirected to the jenkins dashboard page.
From here you can use jenkins to create and build jobs.