In this article, we’ll explain how to install Jenkins on Ubuntu 20.04
Jenkins is a free and open source automation server. Jenkins provides hundreds of plugins to support building, deploying and automating any project. Jenkins is Java-based, installed from Ubuntu packages or by downloading and running its web application archive (WAR) file — a collection of files that make up a complete web application to run on a server.
- A Ubuntu 20.04 installed dedicated server or KVM VPS.
- A root user access or normal user with administrative privileges.
How to Install Jenkins on Ubuntu
Step 1 – Keep your server up to date
# apt-get update -y
# apt-get upgrade -y
Step 2 – Install Java
Next, we will install OpenJDK 11.
# apt-get install -y default-jre
To verify the installation, check the version using following command:
# java -version
The output will be similar to the following:
openjdk version “11.0.10” 2021-01-19
OpenJDK Runtime Environment (build 11.0.10+9-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.10+9-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)
Step 3 – Install Jenkins
Following command will install LTS release. LTS is chosen every 12 weeks from the stream of regular releases as the stable release for that time period.
Use following commands to install Jenkins:
# wget -q -O – https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add –
# sudo sh -c ‘echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list’
# sudo apt-get update
# sudo apt-get install jenkins -y
Now that Jenkins and its dependencies are in place, we’ll start the Jenkins server.
Step 4 – Start and enable Jenkins
We need to start and enable Jenkins service. Use following commands:
# systemctl start jenkins
# systemctl enable jenkins
Step 5 – Configure Firewall (Optional)
Assuming that you are using UFW firewall. By default, Jenkins runs on port 8080. We’ll open that port using ufw:
# ufw allow 8080
Check ufw’s status to confirm the new rules:
# ufw status
Step 5 – Setup Jenkins
First, we need to get default administrator password.
# cat /var/lib/jenkins/secrets/initialAdminPassword
Above command will display administrator password. Copy the 32-character alphanumeric password from the terminal and paste it into the Administrator password field, then click Continue.
Once you click to continue, you will get two options. You can select any option as per your choice or we suggest to go with Install Suggested Plugins. Once you click the Install suggested plugins option, which will immediately begin the installation process.
After that it will ask to create admin user. It’s possible to skip this step and continue as admin using the initial password we used above, but we recommend to take a moment to create the user.
Next, you’ll receive an Instance Configuration page that will ask you to confirm the preferred URL for your Jenkins instance. Confirm either the domain name for your server or your server’s IP address.
After confirming the appropriate information, click Save and Finish. You’ll receive a confirmation page confirming that “Jenkins is Ready!”
That’s it. The installation and configuration process has been completed successfully.
In this article, we have seen how to install Jenkins on Ubuntu 20.04.