Jenkins is an open-source automation server that helps to automate the repetitive tasks involved in the software development process, which includes building, testing, and deployments.
Jenkins was forked from the Oracle Hudson project and written in Java.
Here, we will see how to install Jenkins on Ubuntu 20.04 / Ubuntu 18.04.
Install Jenkins On Ubuntu 20.04
Since Jenkins is written in Java, it requires Java 8 or Java 11 to run. Here, I will install the OpenJDK 11 for Jenkins installation.
sudo apt update sudo apt install -y default-jre apt-transport-https wget
If you want to use the Oracle Java in place of OpenJDK, then use any one of the links to install it.
READ: How To Install Oracle Java on Ubuntu 20.04
READ: How To Install Oracle Java on Ubuntu 18.04
Verify the Java version after the installation.
openjdk version "11.0.8" 2020-07-14 OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu120.04) OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)
Add Jenkins Repository
Jenkins provides an official repository for its packages. To use the Jenkins repository, first, we will need to add the Jenkins public key to the system.
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
Then, add the Jenkins repository to your system.
echo "deb https://pkg.jenkins.io/debian-stable binary/" | sudo tee /etc/apt/sources.list.d/jenkins.list
Install Jenkins package using the apt command.
sudo apt update sudo apt install -y jenkins
The Jenkins service should now be up and running. You can check the status of the Jenkins service using the below command.
sudo systemctl status jenkins
Open up a web browser and navigate it to the following URL to set up Jenkins.
For security reasons, Jenkins package puts up an initial password in /var/lib/Jenkins/secrets/initialAdminPassword file to prevent unauthorized Jenkins installation.
Use the cat command to see the initial password.
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Copy and paste the above password on Jenkins setup wizard. Then, click on Continue.
You can choose to either install suggested plugins or select plugins to install that is most suitable for your needs.
Wait for the Jenkins plugins installation to complete. The installation of plugins may take 5 to 10 minutes to complete.
Once the installation of the plugins is complete, create the first admin user for Jenkins.
Set up Jenkins URL, which will provide the root URL for links to various Jenkins resources.
Jenkins is now ready for your automation jobs. Click on Start using Jenkins to access Jenkins.
Open up a web browser and navigate it to the following URL.
Log in with the Jenkins admin account that you created earlier.
Create Jenkins Job
Let us test the Jenkins automated build by creating a sample build job with a shell command.
That’s All. You have successfully installed Jenkins on Ubuntu 20.04 / Ubuntu 18.04. I recommend you to visit Jenkins’s documentation for more information.