How to Install Jenkins on Debian 11

Jenkins is an open-source automation and continuous integration tool that helps to automate the repetitive tasks involved in the software development process. It is written in Java used by software developers to automate different aspects of building, testing, delivering, and deploying software applications.

This tutorial will explain how to install Jenkins continuous integration system on Debian 11 system.

Prerequisites

  • A server running Debian 11.
  • A root password is configured on the server.

Install Java

Jenkins is a Java-based tool so Java must be installed in your system. If not installed, you can install it using the following command:

apt-get install default-jre gnupg2 apt-transport-https wget -y

Once the Java is installed, verify the Java version using the following command:

java -version

You should get the following output:

openjdk version "11.0.12" 2021-07-20
OpenJDK Runtime Environment (build 11.0.12+7-post-Debian-2)
OpenJDK 64-Bit Server VM (build 11.0.12+7-post-Debian-2, mixed mode, sharing)

Add Jenkins PPA

By default, Jenkins is not included in the Debian 11 default repository. So you will need to add the Jenkins PPA to your system.

First, download and add the GPG key with the following command:

wget https://pkg.jenkins.io/debian-stable/jenkins.io.key
apt-key add jenkins.io.key

Next, add the Jenkins PPA with the following command:

echo "deb https://pkg.jenkins.io/debian-stable binary/" | tee /etc/apt/sources.list.d/jenkins.list

Install Jenkins on Debian 11

Once Jenkins PPA has been added, you can update the repository cache with the following command:

apt-get update -y

Next, install the Jenkins with the following command:

apt-get install jenkins -y

After the installation, verify the Jenkins status using the following command:

systemctl status jenkins

You should see the following output:

? jenkins.service - LSB: Start Jenkins at boot time
     Loaded: loaded (/etc/init.d/jenkins; generated)
     Active: active (exited) since Sat 2021-09-18 15:07:22 UTC; 16s ago
       Docs: man:systemd-sysv-generator(8)
    Process: 23958 ExecStart=/etc/init.d/jenkins start (code=exited, status=0/SUCCESS)
        CPU: 137ms

Sep 18 15:07:21 debian11 systemd[1]: Starting LSB: Start Jenkins at boot time...
Sep 18 15:07:21 debian11 jenkins[23958]: Correct java version found
Sep 18 15:07:21 debian11 su[23991]: (to jenkins) root on none
Sep 18 15:07:21 debian11 su[23991]: pam_unix(su-l:session): session opened for user jenkins(uid=108) by (uid=0)
Sep 18 15:07:21 debian11 su[23991]: pam_unix(su-l:session): session closed for user jenkins
Sep 18 15:07:22 debian11 jenkins[23958]: Starting Jenkins Automation Server: jenkins.
Sep 18 15:07:22 debian11 systemd[1]: Started LSB: Start Jenkins at boot time.

By default, Jenkins listens on port 8080. You can check it with the following command:

ss -antpl | grep 8080

You should see the following output:

LISTEN 0      50                 *:8080            *:*    users:(("java",pid=24017,fd=120))                                                                                                                                                                                                                                                                               

Access Jenkins Web UI

To access the Jenkins web interface, open your web browser and type the URL http://your-server-ip:8080. You should see the following page:

Getting Started with Jenkins

To find the Jenkins password, open your terminal and run the following command:

cat /var/lib/jenkins/secrets/initialAdminPassword

You should see the following output:

76ad882e7e7a459088f7a03d022bce76

Now, paste the above password into the Jenkins screen and click on the Continue button. You should see the following page:

Customize Jenkins

Select Install Suggested Plugins and the installation process will start immediately. Once the installation has been completed, you should see the following page:

Getting Started

Create admin user

Provide your admin username, password and click on the Save and Continue button. You will be redirected to the following page:

Instance configuration

Provide your Jenkins URL and click on the Save and Finish button. You should see the following page:

Jenkins Dashboard

Create a Jenkins Job

In this section, we will create a sample build with a shell command.

Go to the Jenkins Dashboard => New Item. You should see the following page:

Create Job in Jenkins

Provide your project name, select a Freestyle project and click on the OK button. You should see the following page:

Build Environment

Scroll down and select the Execute shell as Add build step in the Build section then add the following command to execute while building the project.

echo "This is $JOB_NAME"

Next, click on the Save button. You should see the following page:

Jenkins Project

Now, click on the Build Now button. You should see the following page:

Build project

You can now click on Console Icon to see the output of your build on the following page:

Console Output

Conclusion

Congratulations! you have successfully installed Jenkins on Debian 11. You can now implement Jenkins in your development environment. For more information, visit the Jenkins documentation page. 

Share this page:

Suggested articles

0 Comment(s)

Add comment