Are you trying to install Jenkins on Ubuntu 18.04 ?
This guide is for you.
When installing Jenkins you need to go through some procedures such as opening firewall ports and its initial setup.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform Software Installation tasks on their Servers.
In this context, we shall look into the steps to install Jenkins on Ubuntu 18.04.
How to install Jenkins on Ubuntu 18.04 ?
Jenkins is a Java-based open source automation server that helps to repetitive technical tasks.We can install it from the Ubuntu packages or can download and install its WAR file.
Installation of Jenkins in Ubuntu involve the steps given below:
i. Installing Jenkins.
ii. Starting Jenkins.
iii. Opening the Firewall.
iv. Setting up Jenkins.
Now let us take a look at each one in details.
1. Installing Jenkins
Often the Jenkins version within the default Ubuntu packages is not the latest one. Latest fixes and features may not be available with this version.
To make use of these fixes and features, we will use the project-maintained packages to install Jenkins.
i. First, we will add the repository key to the system.
$ wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
ii. When the key is added, the system will return OK. Next, we will append 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
iii. When both of these are in place, we will run update so that apt-get will use the new repository:
$ sudo apt-get update
iv. Finally, we will install Jenkins and its dependencies, including Java:
$ sudo apt-get install jenkins
Now that Jenkins and its dependencies are in place, we will start the Jenkins server.
2. Starting Jenkins
i. We can start Jenkins using systemctl command below:
$ sudo systemctl start jenkins
ii. Now to verify that it is started successfully, use the command below. The output should show that the service is active and configured to start at boot:
$ sudo systemctl status jenkins
● 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
Now that Jenkins is running, we will adjust our firewall rules so that we can reach Jenkins from a web browser to complete the initial set up.
3. Opening the Firewall
The default port for Jenkins is port 8080. Thus, we need to open this port in the firewall to allow access.
i. To open port using ufw, follow the steps below:
$ sudo ufw allow 8080
ii. We can see the new rules by checking UFW’s status.
$ sudo ufw status
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
8080 ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
8080 (v6) ALLOW Anywhere (v6)
It shows that the 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.
4. Setting up Jenkins
To complete the installation process, we need to set up Jenkins.
We can visit Jenkins on its default port, 8080, using the server domain name or IP address. For instance, http://ip_address_or_domain_name:8080
We should see the “Unlock Jenkins” screen, which displays the location of the initial password.
The administrative password is available in the file “/var/lib/jenkins/secrets/initialAdminPassword”.
We could use the cat command in the terminal to display the password.
Now, 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 will click the “Install suggested plugins” option, which will immediately begin the installation process.
When the installation is complete, it asks to set up the first administrative user. It is possible to skip this step and continue as admin using the initial password we used above, but we will take a moment to create the user.
We have to configure SSL on the Jenkins server to protect user credentials and information about builds that are transmitted via the Web interface.
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.