1. Home
  2. Linux
  3. Ubuntu
  4. Installing Jenkins for Ubuntu 16.04

Installing Jenkins for Ubuntu 16.04

Installing Jenkins for Ubuntu 16.04
Installing Jenkins for Ubuntu 16.04

About Jenkins

Jenkins is an open source automation server meant to automate repeating technical tasks as part of the continuous integration and delivery of software. Jenkins is Java-based and can be installed from Ubuntu packages or by downloading and using its Web Application Archive (WAR) file, a group of files which create an entire web application meant for running on a server.
In this tutorial we will teach you how to install Jenkins by adding its Debian package repository and using that repository to install the package with apt-get.

Requirements

For this guide you will need the following:
An Ubuntu 16.04 server configured with a non-root sudo user and a firewall; we suggest beginning with at least 1 GB of Ram.
After the server is set up, you are prepared to use this tutorial.

Installing Jenkins

Generally, the version of Jenkins in the default Ubuntu package is not the latest one; to be able to take advantage of the latest fixes and features, you should use the project-maintained packages to install Jenkins.
To begin, append the repository key to the system.

wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -

Once you have the key added, the system is going to return an OK. Then, add the Debian package repository address to the server’s ‘sources.list’.

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

After both of those are in place, execute the update so that apt-get uses the latest repository available.

sudo apt-get update

Lastly, install Jenkins along with the dependencies, and Java as well.

sudo apt-get install jenkins

Since you have got Jenkins and its dependencies in place, you can now run the Jenkins server.

Starting Jenkins

With the command below, you can run Jenkins.

sudo systemctl start jenkins

Because ‘systemctl’ will not have a display output, you should use the status command to confirm it has started properly.

sudo systemctl status Jenkins

If everything is well, the start of the output will show that the service is up and configured to start at boot.

Output
jenkins.service - LSB: Start Jenkins at boot time
  Loaded: loaded (/etc/init.d/jenkins; bad; vendor preset: enabled)
  Active:active (exited) since Thu 2017-04-20 16:51:13 UTC; 2min 7s ago
   Docs: man:systemd-sysv-generator(8)

Since Jenkins is running, you will need to adjust your firewall rules so that you may reach Jenkins from a web browser to finish the initial set up.

Opening the Firewall

Automatically, Jenkins will be using port 8080, so you will want to open that port with UFW.

sudo ufw allow 8080

Now you will be able to see the new rules by checking UFW’s status.

sudo ufw status

You will want to see that the 8080 port allows traffic from anywhere.

Output
Status: active
To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere
8080                       ALLOW       Anywhere
OpenSSH (v6)               ALLOW       Anywhere (v6)
8080 (v6)                  ALLOW       Anywhere (v6)

Setting up Jenkins

To set up your installation, go to Jenkins located on its default port, 8080, we can do this with the server’s domain name or IP address.
http://ip_address_or_domain_name:8080
Now you will see the ‘Unlock Jenkins’ screen which should present the location of the initial password.
Once you are in the terminal window, you can use the cat command to present the command below.

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

First, select the 32-character alphanumeric password in the terminal and copy it into your clipboard, then paste it into the ‘Administrator Password’ field, then click ‘Continue’.
Once you have reached the next screen, it will display the option to install suggested plugins or specific ones that you would like.
Now, use the ‘install suggested plugins’ option which should instantly start the installation procedure.
After the installation is complete you will be asked to setup the first administrative user, feel free to skip this step and proceed as admin with the initial password you used in the last step, however you should take a second to create the user.
Finally, after the first admin user is in place, you will see a ‘Jenkins is ready’ confirmation screen.
Click ‘Start using Jenkins’ to go to the main Jenkins dashboard.
At this point, Jenkins should have been successfully installed.

Conclusion

You have now installed Jenkins with the project-given packages, started the server opened the firewall, and made an administrative user. Now, you can start exploring Jenkins.

Updated on December 23, 2018

Was this article helpful?

Related Articles

Leave a Comment

[apsl-login-lite login_text='Please login with a social account']