Step by Step guide to install Jenkins on ubuntu 16.04

Gaurav Mehla
_devblogs
5 min readAug 25, 2017

--

Introduction

Jenkins is an open source automation server intended to automate repetitive technical tasks involved in the continuous integration and delivery of software.

Continuous Integration is a development practice that requires developers to integrate code into a shared repository at regular intervals. This concept was meant to remove the problem of finding later occurrence of issues in the build lifecycle. Continuous integration requires the developers to have frequent builds. The common practice is that whenever a code commit occurs, a build should be triggered.

Jenkins is Java-based and can be installed from Ubuntu packages or by downloading and running its WAR file — used to distribute a collection of JavaServer Pages, Java Servlets, Java classes and other resources that together constitute a web application.

Jenkins will be installed on a server where the central build will take place. The following flowchart demonstrates a very simple workflow of how Jenkins works.

Prerequisites

Before proceeding further, you mush have a server on which we are going to install Jenkins. If you do not have a server right now, follow this guide before proceeding further.

⚠️ Its recommended to start with at least 1GB of RAM.

When the server is set up, you are ready to follow along.

Installing Jenkins

The version of Jenkins included with the default Ubuntu packages is often behind the latest available version from the project itself. In order to take advantage of the latest fixes and features, we’ll use the project-maintained packages to install Jenkins.

  • First, we’ll add the repository key to the system.
  • If the system will return OK, it means the key is added successfully. Next, we’ll append the Debian package repository address to the server’s sources.list
  • When both of these are in place, we’ll run updateso that apt-getwill use the new repository
  • Finally, we’ll install Jenkins and its dependencies, including Java

Now that Jenkins and its dependencies are in place, we’ll start the Jenkins server.

Starting Jenkins Server

Using systemctl we’ll start Jenkins :

Since systemctl doesn’t display output, we’ll use its status command to verify that it started successfully

If everything went well, the beginning of the output should show that the service is active and configured to start at boot

Now that Jenkins is running, we’ll adjust our firewall rules so that we can reach Jenkins from a web browser to complete the initial set up.

Opening the firewall

By default, Jenkins runs on port 8080, so we’ll open that port using ufw:

⚠️ First make sure ufw is enabled. If it is not then enable it using sudo ufw enable. You can also enable it after running above command. Want to read more about ufw click here.

We can see the new rules by checking UFW’s status.

We should see that traffic is allowed to port 8080 from anywhere:

Now that Jenkins is installed and the firewall allows us to access it, we can complete the initial setup.

Setting up Jenkins

To set up our installation, we’ll visit Jenkins by opening web browser and open the link below. Make sure you change ip_address_or_domain_name with your the server domain name or IP address :

Don’t forget to use port 8080.

We should see “Unlock Jenkins” screen, which displays the location of the initial password

In the terminal window, we’ll use the cat command to display the password :

We’ll copy the 32-character alphanumeric password from the terminal and paste it into the “Administrator password” field, then click “Continue”. The next screen presents the option of installing suggested plugins or selecting specific plugins.

We’ll click the “Install suggested plugins” option, which will immediately begin the installation process

When the installation is complete, we’ll be prompted to set up the first administrative user. It’s possible to skip this step and continue as admin using the initial password we used above, but we’ll take a moment to create the user.

Once the first admin user is in place, you should see a “Jenkins is ready!” confirmation screen.

Click “Start using Jenkins” to visit the main Jenkins dashboard :

At this point, Jenkins has been successfully installed.

Conclusion

In this tutorial, we’ve installed Jenkins using the project-provided packages, started the server, opened the firewall, and created an administrative user. At this point, you can start exploring Jenkins.

If you like this article, please ❤/👏 or share it! For more like this, follow me on Medium or Twitter. To ask a Question visit this link. More about me on my website.

--

--

Gaurav Mehla
_devblogs

Software engineer & Web hacker. Spent 30+% of life on playing with JS