Continuous integration is a software development practice in which programmers upload their code to a central repository where they automatically pass quality and metric tests. With this technique, you can detect bugs and keep the code up to date. For these tasks, there are several tools and today we will show you how to install what is perhaps the most popular. In this post, you will learn how to install Jenkins on Ubuntu 20.04.
Jenkins is a Continuous Integration (CI) tool whose purpose is to automate repetitive phases of software development such as builds and unit tests to ensure continuous delivery of functional software.
The application is developed in Java and takes advantage of the latest potentials of this language to allow the extension of its functionalities by making use of plugins, which vary from statistics and execution reports to cluster management and distributed systems.
Also, the application has packages for several distributions, being Ubuntu, Debian, and RHEL-based distributions the ones that take the best advantage of it. Another alternative is to use Docker to deploy it on any server.
In this post, we will use the package that Jenkins distributes for Ubuntu 20.04.
Before starting with the installation of Jenkins the computer must have Java installed. Java is a fundamental requirement for the execution of Jenkins because the latter is created in this language.
So, open a terminal or connect via SSH to the computer.
After that, update the system
sudo apt update sudo apt upgrade
Now proceed to install Java 11 from the official Ubuntu 20.04 repositories by running:
sudo apt install openjdk-11-jre openjdk-11-jdk
You can check the installation, showing the version that has been installed
java – version
After Java, install the
apt-transport-https package needed for the Jenkins repository to be added correctly.
sudo apt install apt-transport-https
Now download and add the GPG key from the repository.
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
Now add the Jenkins repository by modifying the system software source file:
sudo nano /etc/apt/sources.list
And add, at the end of the file, the following line:
deb https://pkg.jenkins.io/debian-stable binary/
Save the changes and exit the text editor.
Now the repository is added, you just have to refresh APT and install Jenkins with this pair of commands
sudo apt update sudo apt install jenkins
Jenkins includes a system service that is automatically started and enabled by the system. You can check the status of the running service:
sudo systemctl status jenkins
● jenkins.service - LSB: Start Jenkins at boot time Loaded: loaded (/etc/init.d/jenkins; generated) Active: active (exited) since Mon 2021-04-05 01:34:57 CEST; 44s ago Docs: man:systemd-sysv-generator(8) Tasks: 0 (limit: 2286) Memory: 0B CGroup: /system.slice/jenkins.service Apr 05 01:34:56 atechtown systemd: Starting LSB: Start Jenkins at boot time... Apr 05 01:34:56 atechtown jenkins: Correct java version found Apr 05 01:34:56 atechtown jenkins: * Starting Jenkins Automation Server jenkins Apr 05 01:34:56 atechtown su: (to jenkins) root on none Apr 05 01:34:56 atechtown su: pam_unix(su-l:session): session opened for user jenkins by (uid=0) Apr 05 01:34:57 atechtown jenkins: ...done. Apr 05 01:34:57 atechtown systemd: Started LSB: Start Jenkins at boot time.
Because Jenkins runs Out-the-box there is not much more to do except to get the initial admin user key with the command
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
We have to copy this initial password because we will need it.
By default, Jenkins works on TCP port 8080. You can change this in the Jenkins configuration file.
sudo nano /etc/default/jenkins
And locate the
HTTP_PORT section and assign the port you want and after closing the editor, restart Jenkins.
Now you can open your web browser and go to
port with the domain or IP address and port you have assigned to Jenkins.
You will see the initial screen where you will have to copy the password you have previously obtained.
Then, you can choose to install the suggested plugins or select the plugins you need.
Continue with the installer until you create the administrator user. You will then have to configure the installation, but you can leave the default settings.
At the end of the whole process, you will see the Jenkins dashboard indicating that it is ready to use.
Jenkins is one of the most important tools for DevOps and all sysdmins who need to automate tasks and deploy programs in production. On the other hand, Jenkins works well thanks to Java and for this reason, it has great support for Linux.