In this article, we will show you how to install Jenkins on Ubuntu server in easy steps which is an open source Java based tool.
Let’s get start Jenkins installation and configuration on ubuntu server.
Install and Configure Jenkins on Ubuntu Server
Before you follow this tutorial, you will need:
- Ubuntu 18.04 Server
- Full SSH root access (or a user with sudo privileges)
Step 1: Let’s connect to your server via SSH as the root user. Login to the ubuntu server and run following command to update it.
sudo apt-get -y update
Step 2: We will install Java 8 OpenJDK by using the following command:
sudo apt install openjdk-8-jdk
Step 3: Use the wget command to import the GPG keys of the Jenkins repository:
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
And run the following command to add the Jenkins repository to the system:
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
Step 4: Once the previous step finished, and we have enabled just before the Jenkins repository in our system, now update the apt package list.
sudo apt-get update -y
Step 5: Now install the latest version of Jenkins:
sudo apt install jenkins
Step 6: Once installation will finished, the application will automatically start. To verify that Jenkins is running on our system, we can run the status command:
sudo systemctl status jenkins
We will get a similar output to this:
● jenkins.service - LSB: Start Jenkins at boot time
Loaded: loaded (/etc/init.d/jenkins; generated)
Active: active (exited) since Fri 2020-09-04 21:37:30 UTC; 1min 48s ago
Docs: man:systemd-sysv-generator(8)
Tasks: 0 (limit: 2332)
CGroup: /system.slice/jenkins.service
Step 7: Execute next command to enable Jenkins for starting during system bootup.
sudo systemctl enable jenkins
We will get a similar output once execution finished-
jenkins.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable jenkins
Step 8: Make some changes in the Firewall, If you are using a firewall, you will need to open ports 80,443 and 8080 to access Jenkins.
sudo ufw allow 80
sudo ufw allow 443
sudo ufw allow 8080
We can verify the changes with the following command:
sudo ufw status
Step 9: To finish the installation of Jenkins, you need to open your browser and type your domain name or your server IP address followed by port 8080.
For example, http://domain_name.com or http://server_IP_address:8080

To unlock Jenkins and start with the web installation, you need to set up the admin password. We will use the cat command so we can display the password in our terminal:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Copy the displayed password from your terminal and paste it into the Administrator password field in the web browser, then click Continue.
Step 9: On the next screen, you need to choose between the options of install suggested plugins or select specific plugins wizard:

Step 10: Once we finished the installation, a prompted will open to set up the first admin user. Fill out the information required and click Save and Continue.

Once you click, will see an Instance Configuration page, Just click on Save & finish the installation wizard.

Once you finished the above wizard, finally you should be able to see the confirmation page that is confirming that “Jenkins is ready!”.

When you proceed with “Start using Jenkins“, you will get redirected to the Jenkins dashboard, and you will also login in as the administrator user you just created before.

Congratulations! You have successfully installed Jenkins on your Ubuntu server, is up and running.
You can now create first Jenkins pipeline to build project. In the future, check Jenkins SSL setup guide if you want to set up SSL on your Jenkins Server to access in your production environment.