How To Setup Jenkins On Ubuntu
In this article , We will learn how to setup and configure Jenkins on Ubuntu.
In my previous article , I have explained How to implement a plugin to automatically create a backup of Jenkins. Check this article.
What Is Jenkins?
Jenkins is an open source continuous integration server , which is written in java.
It is used to automate the tasks which we run it manually as a everyday tasks.
It is used to deploy applications into the server automatically whenever commit occurs Which is also known as Continuous Integration and Delivery mechanism.
PreRequisites
You need an running Ubuntu server , Or , You can create an EC2 Instance using AWS Console , refer this article
Install Java
Jenkins requires java to work. Lets see how to install the java packages in the Ubuntu Operating system.
First , Open the terminal on the Ubuntu server
Using the below command install the java
sudo apt-get install openjdk-8-jdk
Allow for the installation to complete
Do you want to continue? [Y/n] y
Once the installation is completed , Issue the below command , To check the Java version Installed on the system
java --version
You will get the result as shown below:
openjdk 11.0.5 2019-10-15 OpenJDK Runtime Environment (build 11.0.5+10-post-Ubuntu-0ubuntu1.118.04) OpenJDK 64-Bit Server VM (build 11.0.5+10-post-Ubuntu-0ubuntu1.118.04, mixed mode, sharing)
Now Lets go ahead and Install Jenkins on the Ubuntu server.
Installing Jenkins
The default repository of the System will have the outdated version of Jenkins.
To install the latest version of Jenkins with the latest features and fixes , We are going to add the latest Jenkins repository to the Ubuntu server.
Lets add the repository key to the server using the below command,
wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
The system will return the response as OK
Next We will add the repository to the server’s sources.list , Using the below command.
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
Next We have to run the apt-get update , So that the system will use the latest repository
sudo apt-get update
Now we are going to install the jenkins package and its dependencies from the latest repository.
sudo apt-get install jenkins
Once the Jenkins is successfully installed on the server , Start the Jenkins service using the below command.
sudo systemctl start jenkins
To check the status of the Jenkins ,Use the below command,
sudo systemctl status jenkins

To start the jenkins service automatically on system boot , Enable the Jenkins service using the below command.
sudo systemctl enable jenkins
jenkins.service is not a native service, redirecting to systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable jenkins
Now that We have Jenkins service Installed and running Successfully.
By default , Jenkins runs on the port 8080.
Hence We have allow the port 8080 in the Firewall using ufw
sudo ufw allow 8080
To check the firewall status , Issue the below command.
sudo ufw status
Setup Jenkins
To setup Jenkins , We have to access the Jenkins dashboard on the port 8080 using the http://server’s IP Address:8080
You will see the following page.

You can get the administrator password in the below mentioned file , Using the below command.
cat /var/lib/jenkins/secrets/initialAdminPassword
Copy and paste the password and then click Continue
Next You will asked to Customize Jenkins ,

Click Install suggested plugins , Which will start the installation process

Once the installation is completed , You will asked to create an admin user.
We can skip this process and login to Jenkins as admin using the initial password , But Let us create our first admin user and manage Jenkins using this user.

Click Save and Continue
You can configure the root URL for Jenkins , Click Save and Finish.

Now the Jenkins setup is completed and It is ready to use.
Click Start using Jenkins , You will be taken to the Main Jenkins dashboard.

Conclusion
We have successfully Installed and configured Jenkins on the Ubuntu server.
Hope this article helps. Thanks for referring this article.
Check out my other articles.