How To Install Jenkins on Debian 10 / 9 & Ubuntu 18.04 / 16.04

0

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 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 & Ubuntu 18.04 / Ubuntu 16.04.

Prerequisite

Jenkins requires Java 8 or Java 11. Here, i will install the default JRE package.

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 8 / 11 on Debian 10 / Debian 9

READ: How To Install Oracle Java 8 / 11 on Ubuntu 18.04

READ: How To Install Oracle Java 8 / 11 on Ubuntu 16.04

Verify the Java version.

java -version

Output:

openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Debian-1deb10u1)
OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Debian-1deb10u1, mixed mode, sharing)

Install Jenkins

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

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

sudo systemctl status jenkins
Jenkins Service Status
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 reason, Jenkins puts up an initial password in /var/lib/Jenkins/secrets/initialAdminPassword file to prevent unauthorized Jenkins installation.

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

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

Output:

8a742c7b63964879a9a960d737bad789
Jenkins Initial Admin Password
Jenkins Initial Admin Password

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

Unlock Jenkins
Unlock Jenkins

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

Customize Jenkins Installation
Customize Jenkins Installation

Wait for the Jenkins installation to complete.

Installing Jenkins Plugins
Installing Jenkins Plugins

Create the first admin user for Jenkins.

Create Admin User
Create Admin User

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

Jenkins URL
Jenkins URL

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

Jenkins is ready
Jenkins is ready

Jenkins Dashboard:

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
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 new jobs.

Create New Jenkins Job
Create New Jenkins Job

Create a Freestyle project called ITzGeek_Project and then click OK.

New Jenkins Job
New Jenkins Job

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

Execute Shell
Execute Shell

Enter a shell command to execute while building the project.

echo "This is $JOB_NAME"

Click on Save.

Shell Build Command
Shell Build Command

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

Build Now
Build Now

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

View Console
View Console

Console Output:

Console Output
Console Output

Conclusion

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

You might also like