
Jenkins is an open-source automation server that helps developers to automate the software development process including, build, test, and deployment. Jenkins allows you to manage and monitor any code changes in GitHub, Bitbucket, or GitLab and build the code automatically using the tools like Maven and Gradle. Using Jenkins, you can efficiently distribute work across multiple machines.
In this guide, we will show you how to install Jenkins on Ubuntu 20.04.
Table of Contents
Prerequisites
- An Ubuntu 20.04 VPS (we’ll be using our SSD 2 VPS plan)
- Access to the root user account (or access to an admin account with root privileges)
Step 1: Log in to the Server & Update the Server OS Packages
First, log in to your Ubuntu 20.04 server via SSH as the root user:
You will need to replace ‘IP_Address’ and ‘Port_number’ with your server’s respective IP address and SSH port number. Additionally, replace ‘root’ with the username of the admin account if necessary.
Before starting, you have to make sure that all Ubuntu OS packages installed on the server are up to date. You can do this by running the following commands:
Step 2: Install Java
Jenkins is a java-based application. So Java must be installed in your system if not installed you can install it using the following command:
This will install the Java version 11 in your system. You can verify the Java version with the following command:
You should get the following output:
Step 3: Install Jenkins
By default, Jenkins is not available in the Ubuntu standard repository so you will need to add the jenkins repository to your system.
First, install the necessary dependencies with the following command:
Next, download and add the GPG key with the following command:
Next, add the Jenkins repository with the following command:
Once the repository is added, update the repository cache and install the Jenkins with the following command:
After installing Jenkins, verify the status of Jenkins using the command below:
You should get the following output:
Jenkins is now running and listening on port 8080. You can verify it with the following command:
You should get the following output:
Step 4: Configure Nginx as a Reverse Proxy for Jenkins
It is a good idea to use Nginx as a reverse proxy to access the Jenkins. To do so, install the Nginx using the following command:
Once the nginx is installed, create an Nginx configuration file with the following command:
Add the following lines:
Save and close the file then verify the Nginx configuration using the following command:
You should get the following output:
Finally, restart the Nginx service with the following command:
Step 5: Access Jenkins
Now, open your web browser and access the Jenkins web interface using the URL http://jenkins.domain.com
. You should see the following page:
Now, open your terminal and print the Jenkins password using the following command:
You should get the Jenkins admin password in the following output:
Next, back to your web interface and paste the above password and click on the Continue button. You should see the following screen:
Click on the install suggested plugins button. Once all the plugins are installed, you should get the following page:
Provide your desired username, password, email and click on the Save and Continue button. You should see the following page:
Provide your Jenkins website URL and click on the Save and Finish button. You should see the following page:
Click on the Start using Jenkins. You should see the Jenkins default dashboard in the following page:
Of course, you don’t have to do any of this if you use one of our Managed Jenkins VPS Hosting services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.