How To Install Jenkins on Ubuntu 16.04 LTS

As my assume you are System administrator or DevOps guy to read my article to install Jenkins on Ubuntu, I will summary step by step and straight to the point just copy and paste.
Warning: Do not skip any step, you will get an error. To resolve it reset step again and follow one by one.
Step 1: Installing Jenkins
First, we’ll add the repository key to the system.
$ wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
When the key is added, the system will return OK. Next, we’ll append the Debian package repository address to the server’s sources.list:
$ echo deb http://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list
When both of these are in place, we’ll run update so that apt-get will use the new repository:
$ sudo apt-get update
Finally, we’ll install Jenkins and its dependencies, including Java:
$ sudo apt-get install jenkins
Now that Jenkins and its dependencies are in place, we’ll start the Jenkins server.
Step 2 : Starting Jenkins
Using systemctl we’ll start Jenkins:
$ sudo systemctl start jenkins
Since systemctl doesn’t display output, we’ll use its status command to verify that it started successfully:
$ sudo systemctl status jenkins
If everything went well, the beginning of the output should show that the service is active 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 2021-02-20 16:51:13 UTC; 2min 7s ago
Docs: man:systemd-sysv-generator(8)
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.
Step 3 : Opening the Firewall
By default, Jenkins runs on port 8080
, so we’ll open that port using ufw
:
$ sudo ufw allow 8080
We can see the new rules by checking UFW’s status.
$ sudo ufw status
We should see that traffic is allowed to port 8080
from anywhere:
Output
Status: activeTo Action From
-- ------ ----
OpenSSH ALLOW Anywhere
8080 ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
8080 (v6) ALLOW Anywhere (v6)
Step 4 : Setting up Jenkins
To set up our installation, we’ll visit Jenkins on its default port, 8080
, using the server domain name or IP address: http://ip_address_or_domain_name:8080
We should see “Unlock Jenkins” screen, which displays the location of the initial password
You need to to copy admin password in file initialAdminPassword
$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword

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.

Click 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.
I’m sure, the information above will be useful for you. But there are hundreds of other creative people whom it might be useful for as well. So Clap! Clap! :)👏🏼
Conclusion
In this article, you’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.
I recommended you to upgrade HTTP protocol to SSL for protect passwords, as well as any sensitive system or product information that will be sent between your machine and the server in plain text.
I will write two articles which one use Apache2 web server as reverse proxy for Jenkins and Using Nginx Reverse Proxy. you can choose which one is your familiar.
Don’t forget click Clap to help hundreds of other creative people whom it might be useful for as well. So Clap! Clap! :)👏🏼