How to Setup Jenkins on Ubuntu 16.04

Getting started with Jenkins

In this tutorial, we will set up Jenkins by installing the package using apt-get from it’s Debian Package repository.
The Jenkins version is included with the default packages of Ubuntu, therefore to take advantage of the latest features or latest fixes we will use the packages maintained by the project itself to install Jenkins.

Prerequisites

Java version 8 or greater should be available in the environment to install Jenkins.

Installations

  • Add the repository key into your system with below command:
wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
  • Append the Debian package repository address to the server’s sources.list with below command:
echo deb https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list
  • Run the below command to update the packages:
sudo apt-get update
  • Run the below command to install Jenkins in your system with its dependencies:
sudo apt-get install jenkins
  • As Jenkins and its dependencies are installed, run below command to start Jenkins server.
sudo service jenkins start
  • Run the below command to check the Jenkins status:
sudo service jenkins status

● jenkins.service – LSB: Start Jenkins at boot time
Loaded: loaded (/etc/init.d/jenkins; bad; vendor preset: enabled)
Active: active (exited) since Tue 2019-09-19 05:49:26 UTC; 3min 2s ago
Docs: man:systemd-sysv-generator(8)

output

Open the firewall ports

  • To open the port 8080 (default Jenkins port) run below command:
sudo ufw allow 8080
  • To check the firewall status, run below command:
sudo ufw status
  • If the firewall is “inactive”, allow OpenSSH and enable the firewall by running below commands:
sudo ufw allow OpenSSH
sudo ufw enable

The initial setup is completed.

Setting up Jenkins on browser

Open the URL in browser using the server domain name or IP address with the default Jenkins port like below:

  • http://ip_address_or_server_domain_name:8080
  • We should see the screen “Unlock Jenkins”, which shows the path of the initial password.
  • Use the below command to see the initialAdminPassword from Jenkins directory and click on Continue button.
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
  • Click on the “Install suggested plugins” option, which will immediately begin the installation process:
  • After complete installation, we can set up our first administrative user. You can skip this step and can continue as “admin” using that “initial password” we used initially, but you can refer below if you want to create the user.
  • Once the first admin user will be created, now you can see a “Jenkins is ready!” confirmation window.
  • Click on the button, “Start using Jenkins” and then it will prompt you to the Jenkins Dashboard.

Great! Enjoy using Jenkins.

Conclusion

In this article, we have installed and configured the Jenkins using packages, then we have started the server and opened the firewall ports, then created an administrative user. Now you can explore Jenkins.

Related Posts