A Comprehensive Guide to Setting Up a Jenkins Server on Ubuntu/Debian Server
Table of contents
Introduction
Hello everyone,
This article will provide a guide on how to set up a Jenkins server on an Ubuntu or Debian server, covering all the necessary steps to install and configure Jenkins for your needs. As a developer or DevOps engineer, we need Jenkins to help us automate software development processes, and enable us to build, test, and deploy our applications more quickly and efficiently. You can install, configure and start using Jenkins to quickly automate your software development processes by following this article's instructions.
Installation
Let's start by running the sudo apt update
command to update the package lists for repositories configured on our server.
sudo apt update
Java is a prerequisite for running Jenkins. while some Linux distributions do not come with Java by default, so let's install OpenJDK.
sudo apt install openjdk-11-jre
java -version
There are two types of Jenkins releases available: Long Term Support (LTS) and Weekly Release. The LTS release is a stable and reliable version of Jenkins that users can rely on for an extended period of time while the Weekly release is a version of Jenkins that is released every week with the latest features and enhancements. We will be installing the Long Term Support (LTS) version for this article.
## add the Jenkins repository to the list of software repositories
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
## refreshes the package lists for all the repositories on the server
sudo apt-get update
## install jenkins
sudo apt-get install jenkins
With all these done, Jenkins should be properly installed on your server, navigating to your IPAddress:8080 you should have this
Then run this command cat /var/lib/jenkins/secrets/initialAdminPassword
to display your administrator password.
cat /var/lib/jenkins/secrets/initialAdminPassword
Finally, on the next page, install your needed plugins.
If you experience a problem after selecting the suggested plugin or customized plugin on the page for plugin installation type, it could be because the Jenkins server is taking a while to begin after it's been installed. This can take some time based on the hardware and resources available, or it could be the starting process is just taking longer than normal. In my case, I used a digital ocean droplet of 512 MB / 1 CPU for the installation, on getting to the plugin installation stage it gave me an error but it began to work properly after I left it for some time. When I tried the same on a droplet of 1 GB / 1 CPU, it only took a few seconds, which was much quicker than the 512 MB / 1 CPU version.
Conclusion
Some of the steps outlined in this article are based on the official documentation provided by Jenkins for installing the software on Linux. We hope by following the steps outlined in this article, you should now have a fully functional Jenkins server up and running on your Ubuntu/Debian server. If you have any feedback or questions, please feel free to leave a comment below.