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 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:

<img alt="Getting Started with Jenkins" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/09/echo/p1.png6151a229e53a6.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="457" loading="lazy" src="data:image/svg xml,” width=”750″>

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:

<img alt="Customize Jenkins" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/09/echo/p2.png6151a22a19a68.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="476" loading="lazy" src="data:image/svg xml,” width=”750″>

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

<img alt="Getting Started" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/09/echo/p3.png6151a22a5232d.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="464" loading="lazy" src="data:image/svg xml,” width=”750″>

<img alt="Create admin user" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/09/echo/p4.png6151a22a7f71e.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="476" loading="lazy" src="data:image/svg xml,” width=”750″>

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

<img alt="Instance configuration" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/09/echo/p5.png6151a22aca64b.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="465" loading="lazy" src="data:image/svg xml,” width=”750″>

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

<img alt="Jenkins Dashboard" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/09/echo/p7.png6151a22b0eeb2.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="390" loading="lazy" src="data:image/svg xml,” width=”750″>

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:

<img alt="Create Job in Jenkins" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/09/echo/p8.png6151a22b455b8.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="397" loading="lazy" src="data:image/svg xml,” width=”750″>

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

<img alt="Build Environment" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/09/echo/p9.png6151a22b74f83.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="410" loading="lazy" src="data:image/svg xml,” width=”750″>

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:

<img alt="Jenkins Project" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/09/echo/p10.png6151a22ba61f2.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="391" loading="lazy" src="data:image/svg xml,” width=”750″>

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

<img alt="Build project" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/09/echo/p11.png6151a22bdd1b9.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="574" loading="lazy" src="data:image/svg xml,” width=”750″>

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

<img alt="Console Output" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/09/echo/p13.png6151a22c16f51.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="329" loading="lazy" src="data:image/svg xml,” width=”750″>

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. 

<img alt="Hitesh Jethva" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/09/echo/hitesh-80.jpg6151a22c3a212.jpg" ezimgfmt="rs rscb5 src ng ngcb5" src="data:image/svg xml,”>

About Hitesh Jethva

Over 8 years of experience as a Linux system administrator. My skills include a depth knowledge of Redhat/Centos, Ubuntu Nginx and Apache, Mysql, Subversion, Linux, Ubuntu, web hosting, web server, Squid proxy, NFS, FTP, DNS, Samba, LDAP, OpenVPN, Haproxy, Amazon web services, WHMCS, OpenStack Cloud, Postfix Mail Server, Security etc.