Jenkins is the most popular, open source, Java-based automation server, which allows you to easily set up a continuous integration and continuous release pipeline.
Continuous Integration (CI) is a DevOps practice. When team members submit code to the version control warehouse normally, automated builds and tests are run. Continuous release (CD) is a series of practices. When the code is modified, it is automatically built, tested, and released to the production environment.
Jenkins can be installed as a standalone application, installed as a servlet in a Java servlet container (such as Apache Tomcat), or run as a Docker container.
This article explains how to install Jenkins as a standalone service on Ubuntu 20.04.
Jenkins is a Java application and requires Java 8 or later to be installed on the system. We will install OpenJDK 11, an open source implementation of the Java platform.
Run the following command as root or another sudo user to install OpenJDK 11:
sudo apt update
sudo apt install openjdk-11-jdk
Once the installation is complete, verify it by checking the Java version:
java -version
The output should look like this:
openjdk version "11.0.7"2020-04-14
OpenJDK Runtime Environment(build 11.0.7+10-post-Ubuntu-3ubuntu1)
OpenJDK 64-Bit Server VM(build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)
Installing Jenkins on Ubuntu is relatively straightforward. We will enable the Jenkins APT software source, import the source GPGkey, and install the Jenkins package.
Use the following wget
command to import the GPG keys of the Jenkins software source:
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
Next, add the software source to the system:
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
Once the Jenkins repositories are enabled, update the apt
package list and install the latest version of Jenkins:
sudo apt update
sudo apt install jenkins
If you get any message like:
``` bash
Error: W: GPG error: https://pkg.jenkins.io/debian-stable binary/ Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 9B7D32F2D50582E6"
Import key: ```bash
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9B7D32F2D50582E6
After the installation is complete, the Jenkins service will be automatically started. You can verify it by printing the service status:
systemctl status jenkins
You should see a message similar to the following:
● jenkins.service - LSB: Start Jenkins at boot time
Loaded:loaded(/etc/init.d/jenkins; generated)
Active:active(exited) since Thu 2020-07-1620:22:12 UTC; 15min ago
...
If you are installing Jenkins on a remote server and the server is protected by a firewall, you will need to open port 8080
.
Usually, you will only allow access to the Jenkins server from the specified IP address or IP range. For example, to allow access from "192.168.121.0/24", you will need to run the following command:
sudo ufw allow proto tcp from192.168.121.0/24 to any port 8080
If you need to allow access from anywhere, run:
sudo ufw allow 8080
To set up a new Jenkins installation, open your browser, enter your domain name or IP address, plus port 8080, http://your_ip_or_domain:8080
.
A page similar to the following will be displayed, prompting you to enter the administrator password during the installation process:
Use cat
to display the password in the terminal:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
You should see a 32-character password, including letters and numbers, like this:
06 cbf25d811a424bb236c76fd6e04c47
Copy this password from the terminal, paste it into the "Administrator password" text field, and click "Continue".
On the next screen, the graphical interface will ask you whether you want to install the recommended plug-in, or if you choose the specified plug-in:
Click "Install suggested plugins" and the installation process will start immediately:
Once the plugin is installed, you will be prompted to set up the first administrator account. Fill in the necessary information and click "Save and Continue".
The next page will ask you to set the URL address of the Jenkins instance. This text field will be automatically filled in the generated URL.
Confirm the URL by clicking the "Save and Finish" button, and the setup process will be completed.
Click the "Start using Jenkins" button and you will be redirected to the Jenkins backend and log in as the administrator user you created earlier.
At this point, you have successfully installed Jenkins on your server.
In this guide, we have shown you how to install Jenkins and complete the initial setup on an Ubuntu system.
You can now browse Jenkins official documentation, and start exploring the workflow and plug-in mode of Jenkins.
Original: https://linuxize.com/post/how-to-install-jenkins-on-ubuntu-20-04/
Copyright notice: This work uses Creative Commons attribution-Share 4 in the same way.0 International license agreement for licensing.
Recommended Posts