In this tutorial, we are going to explain in step-by-step detail how to Install Jenkins on Debian 11 OS.<\/p>\r\n\r\n\r\n\r\n
Jenkins is a free open source continuous integration system tool written in Java, that helps developers to keep the code up to date in one place from different local machines. It is used for code automatic deployment, testing, building applications, and kind of securement that the latest code changes are always in the software.<\/p>\r\n\r\n\r\n\r\n
Table of Contents<\/p>\n
Since we have a fresh installation of Debian 11, we need to update the packages to its latest versions available:<\/p>\r\n\r\n\r\n\r\n
sudo apt update -y && sudo apt upgrade -y<\/pre>\r\n\r\n\r\n\r\n<\/span>Step 2. Install Java<\/span><\/h2>\r\n\r\n\r\n\r\n
Jenkins is written in Java, and that is why we need the Java installed on our system along with some dependencies:<\/p>\r\n\r\n\r\n\r\n
sudo apt install openjdk-11-jdk default-jre gnupg2 apt-transport-https wget -y<\/pre>\r\n\r\n\r\n\r\nTo check whether Java is installed execute the following command:<\/p>\r\n\r\n\r\n\r\n
java -version<\/pre>\r\n\r\n\r\n\r\nYou should receive the following output:<\/p>\r\n\r\n\r\n\r\n
root@vps:~# java -version\r\nopenjdk version \"11.0.14\" 2022-01-18\r\nOpenJDK Runtime Environment (build 11.0.14+9-post-Debian-1deb11u1)\r\nOpenJDK 64-Bit Server VM (build 11.0.14+9-post-Debian-1deb11u1, mixed mode, sharing)<\/pre>\r\n\r\n\r\n\r\n<\/span>Step 3. Add Jenkins GPG key and PPA<\/span><\/h2>\r\n\r\n\r\n\r\n
By default the repository of Debian 11, does not contain the Jenkins, so we need to add manually the key and the PPA.<\/p>\r\n\r\n\r\n\r\n
wget https:\/\/pkg.jenkins.io\/debian-stable\/jenkins.io.key\r\n\r\nsudo apt-key add jenkins.io.key<\/pre>\r\n\r\n\r\n\r\nOnce, the GPG key is added next is to add the PPA:<\/p>\r\n\r\n\r\n\r\n
echo \"deb https:\/\/pkg.jenkins.io\/debian-stable binary\/\" | tee \/etc\/apt\/sources.list.d\/jenkins.list<\/pre>\r\n\r\n\r\n\r\nUpdate the repository before you install Jenkins:<\/p>\r\n\r\n\r\n\r\n
sudo apt update -y<\/pre>\r\n\r\n\r\n\r\nOnce, the system is updated with the latest packages, install Jenkins.<\/p>\r\n\r\n\r\n\r\n
<\/span>Step 4. Install Jenkins<\/span><\/h2>\r\n\r\n\r\n\r\n
sudo apt-get install jenkins -y<\/pre>\r\n\r\n\r\n\r\nAfter the installation, start and enable the Jenkins service, in order for the service to start automatically after system reboot.<\/p>\r\n\r\n\r\n\r\n
sudo systemctl start jenkins && sudo systemctl enable jenkins<\/pre>\r\n\r\n\r\n\r\nTo check the status of the service execute the following command:<\/p>\r\n\r\n\r\n\r\n
sudo systemctl status jenkins<\/pre>\r\n\r\n\r\n\r\nYou should receive the following output:<\/p>\r\n\r\n\r\n\r\n
root@vps:~# sudo systemctl status jenkins\r\n\u25cf jenkins.service - LSB: Start Jenkins at boot time\r\n Loaded: loaded (\/etc\/init.d\/jenkins; generated)\r\n Active: active (exited) since Sat 2022-02-12 04:50:43 EST; 1min 35s ago\r\n Docs: man:systemd-sysv-generator(8)\r\n Tasks: 0 (limit: 4678)\r\n Memory: 0B\r\n CPU: 0\r\n CGroup: \/system.slice\/jenkins.service\r\n\r\nFeb 12 04:50:41 test.vps systemd[1]: Starting LSB: Start Jenkins at boot time...\r\nFeb 12 04:50:41 test.vps jenkins[37526]: Correct java version found\r\nFeb 12 04:50:42 test.vps su[37564]: (to jenkins) root on none\r\nFeb 12 04:50:42 test.vps su[37564]: pam_unix(su-l:session): session opened for user jenkins(uid=114) by (uid=0)\r\nFeb 12 04:50:42 test.vps su[37564]: pam_unix(su-l:session): session closed for user jenkins\r\nFeb 12 04:50:43 test.vps jenkins[37526]: Starting Jenkins Automation Server: jenkins.\r\nFeb 12 04:50:43 test.vps systemd[1]: Started LSB: Start Jenkins at boot time.<\/pre>\r\n\r\n\r\n\r\nAnother way to check if Jenkins, is active and running is to check port 8080<\/b><\/p>\r\n\r\n\r\n\r\n
netstat -tunlp | grep 8080<\/pre>\r\n\r\n\r\n\r\nYou should receive the following output:<\/p>\r\n\r\n\r\n\r\n
root@vps:~# netstat -tunlp | grep 8080\r\ntcp6 0 0 :::8080<\/b> :::* LISTEN 37591\/jenkins<\/b>: \/usr<\/pre>\r\n\r\n\r\n\r\n<\/span>Step 5. Finish Jenkins Installation<\/span><\/h2>\r\n\r\n\r\n\r\n
After successful installation we can finish the installation by accessing the Jenkins Web Interface:<\/p>\r\n\r\n\r\n\r\n
http:\/\/YourServerIPaddress:8080<\/b><\/pre>\r\n\r\n\r\n\r\nYou should see the screen below:<\/p>\r\n\r\n\r\n\r\n
<\/figure>\r\n\r\n
The Jenkins is asking the administrator<\/b> in the order to be unlocked. To find the administrator password execute the following command:<\/p>\r\n
cat \/var\/lib\/jenkins\/secrets\/initialAdminPassword<\/pre>\r\nThe output of the administrator password will be as described below:<\/p>\r\n
root@vps:~# cat \/var\/lib\/jenkins\/secrets\/initialAdminPassword\r\ne5bcfa4486dd412f988a4762a8535aa3<\/b><\/pre>\r\nCopy the administrator password, paste in the input of the Jenkins interface and click on the “Continue<\/b>” button.<\/p>\r\n\r\n
<\/figure>\r\n\r\n
On the next screen there will be two choices, for plugin selection. We will use default suggested plugins:<\/p>\r\n\r\n
<\/figure>\r\n\r\n
There will be some configuration checks:<\/p>\r\n\r\n
<\/figure>\r\n\r\n
Once, the checks are passed create the first Admin user and hit on Save and Continue<\/b> button:<\/p>\r\n\r\n
<\/figure>\r\n\r\n
On the next window there will be displayed your Jenkins URL containng the IP address<\/b> and port 8080<\/b>.<\/p>\r\n\r\n
<\/figure>\r\n\r\n
Click on the Save and Finish<\/b> button.<\/p>\r\n\r\n
<\/figure>\r\n\r\n
Jenkins is installed and is ready for use. When you click on the Start using Jenkins<\/b> button you will be logged in to the Jenkins admin dashboard<\/p>\r\n\r\n
<\/figure>\r\n\r\n
<\/span>Step 6. Setting up Apache as a Reverse Proxy<\/span><\/h2>\r\n
If you want to access your Jenkins installation via domain, you need to configure the Apache as a Reverse Proxy. First install the Apache Web server:<\/p>\r\n
sudo apt install apache2<\/pre>\r\nStart and enable the Apache service:<\/p>\r\n
sudo systemctl start apache2 && sudo systemctl enable apache2<\/pre>\r\nCheck the status of the Apache service:<\/p>\r\n
sudo systemctl status apache2<\/pre>\r\nYou should receive the following output:<\/p>\r\n
root@vps:~# sudo systemctl status apache2\r\n\u25cf apache2.service - The Apache HTTP Server\r\n Loaded: loaded (\/lib\/systemd\/system\/apache2.service; enabled; vendor preset: enabled)\r\n Active: active (running) since Fri 2022-02-11 19:25:48 EST; 10h ago\r\n Docs: https:\/\/httpd.apache.org\/docs\/2.4\/\r\n Main PID: 715 (apache2)\r\n Tasks: 7 (limit: 4678)\r\n Memory: 20.0M\r\n CPU: 5.870s\r\n CGroup: \/system.slice\/apache2.service<\/pre>\r\nOnce, the Apache is installed create the jenkins.conf<\/b> configuration file<\/p>\r\n
cd \/etc\/apache2\/sites-available\/
\r\nsudo nano jenkins.conf<\/pre>\r\nPaste the following lines of code, save and close the file.<\/p>\r\n
<Virtualhost *:80>\r\n ServerName yourdomain.com<\/b>\r\n ProxyRequests Off\r\n ProxyPreserveHost On\r\n AllowEncodedSlashes NoDecode\r\n\r\n <Proxy http:\/\/localhost:8080\/*>\r\n Order deny,allow\r\n Allow from all\r\n <\/Proxy>\r\n\r\n ProxyPass \/ http:\/\/localhost:8080\/ nocanon\r\n ProxyPassReverse \/ http:\/\/localhost:8080\/\r\n ProxyPassReverse \/ http:\/\/yourdomain.com\/<\/b>\r\n<\/Virtualhost><\/pre>\r\nOnce, you save and close the file you need to execute the following commands:<\/p>\r\n
sudo a2ensite jenkins\r\nsudo a2enmod proxy\r\nsudo a2enmod proxy_http\r\nsudo a2enmod headers\r\nsudo systemctl restart apache2<\/pre>\r\nAfter enabling the Apache configuration and restarting the Apache service you will be able to access your Jenkins via your domain:<\/p>\r\n
http:\/\/yourdomain.com<\/b><\/pre>\r\nThat’s all. You successfully installed and configured Jenkins<\/a> on Debian 11. If you don’t know, something about the installation process and you find any difficulties feel free to contact our technical support and they will do the rest. We are available 24\/7. All you need to do is to sign up for one of our SSD VPS plans and submit a support ticket.<\/p>\r\n
If you liked this post on how to install Jenkins on Debian 11<\/a>, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>","protected":false},"excerpt":{"rendered":"