How To Install Jenkins on Debian 10 / Debian 9

Jenkins is an open-source automation server; in other words, a continuous integration tool written in Java that helps to automate the repetitive tasks involved in the software development process. Repetitive tasks could be like software build, testing, and deployments.

Jenkins project was forked from the Oracle Hudson project after a dispute in early 2011, but, still each call other as a fork.

Here, this tutorial guides you through the installation of Jenkins on Debian 10 / Debian 9.

Install Jenkins On Debian

Install Java

Jenkins requires Java 8 or Java 11. Here, I will install the default JRE package (OpenJDK).

sudo apt update

sudo apt install -y default-jre apt-transport-https wget

If you want to use the Oracle JAVA instead of OpenJDK, then use any one of the links for guidance.

READ: How To Install Oracle Java on Debian 10 / Debian 9

Verify the Java version.

java -version

Output:

openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Debian-3deb10u1)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Debian-3deb10u1, mixed mode, sharing)

Add Jenkins repository

Let’s add Jenkins repository as the Jenkins is not available on Debian / Ubuntu OS base repositories.

First, add the Jenkins public key to the system.

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

sudo apt-key add jenkins.io.key

Now, add the Jenkins repository to your system.

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

Install Jenkins

Install Jenkins package using the apt command.

sudo apt update

sudo apt install -y jenkins

The Jenkins service should now be up and running. Check the status of Jenkins service using the below command.

sudo systemctl status jenkins
Jenkins Service Status

Setup Jenkins

Jenkins comes with a web interface where you can build, test, and deploy software.

Open up a web browser and navigate it to the following URL.

http://your.ip.add.ress:8080

For security reasons, Jenkins puts up an initial password in /var/lib/Jenkins/secrets/initialAdminPassword file to prevent unauthorized Jenkins installation.

Use the cat command to see the password for Jenkins installation.

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Output:

15d5552f98af42d78660c86edf03d43c
Jenkins Initial Admin Password

Copy and paste the password on Jenkins setup wizard. Then, click on Continue.

Unlock Jenkins

You can either install suggested plugins or select and install plugins most suitable for your needs.

Customize Jenkins Installation

Wait for the Jenkins plugins installation to complete.

Installing Jenkins Plugins

Create the first admin user for Jenkins.

Create Admin User

Set up Jenkins URL, which will provide the root URL for links to various Jenkins resources.

Jenkins URL

Jenkins is now ready for building software. Click on Start using Jenkins.

Jenkins is ready

Jenkins Dashboard:

Jenkins Dashboard

Access Jenkins

Open up a web browser and navigate it to the following URL.

http://your.ip.add.ress:8080

Log in with the Jenkins admin account, which you created earlier.

Jenkins Login Page

Create Jenkins Job

Let’s create a sample build with a shell command.

To do that, go to Jenkins Dashboard >> New Item or Create a job.

Create New Jenkins Job

Create a Freestyle project called ITzGeek_Project and then click OK.

New Jenkins Job

On the project configuration page, scroll down and choose Execute shell as Add build step in the Build section.

Execute Shell

Enter a shell command to execute while building the project.

echo "This is $JOB_NAME"

Click on Save.

Shell Build Command

The project is now ready to build. Click on Build Now in the left pane to build the project.

Build Now

Click on Console Icon to see the output of your build.

View Console

Console Output:

Console Output

Conclusion

That’s All. You have successfully installed Jenkins on Debian 10 / Debian 9. I recommend you to visit Jenkins’s documentation for more information.

debian 10debian 9devopsjenkins
Comments (0)
Add Comment