How to Install Jenkins on Debian 11 Server (CI CD Open Source). In this article we will introduce What Jenkins is with it’s advantages and move onto installation phase on Debian. Let’s start.
What is Jenkins
Jenkins is a (CICD)Continuous Integration and Continuous Delivery tool, which is considered to be the most integral part of DevOps tools. It is capable of setting up the CI/CD environment for almost any combination of languages and source codes. It provides its user with a faster and more robust way of integrating their entire chain of build, test and deployment tools. This way, developers can continuously work on the improving the product by integrating changes to the project.
This open source tool is written entirely in Java. You can execute a series of actions to achieve the continuous integration process. Moreover, Jenkins server automates software build consistently, thereby allowing developers to know about the errors at an early stage.
The possible steps Jenkins users can perform are:
Building software using build systems like Git, Maven and more.
Testing automating using test frameworks like Nose2, PyTest, Robot, Selenium, etc.
Executing test scripts.
Achieving test results and performing post actions.
Executing test scenarios against different input combinations for obtaining input test coverage.
Next in this post how to Install Jenkins on Debian 11 Server (CI CD Open Source) we talk about Jenkins pros.
Although Jenkins is not the only option for CI integration, its characteristics make it a contender for diverse development scenarios. In this blog how to install Jenkins on Debian 11 Server (CI CD Open Source) let’s talk about benefits it provides to the DevOps teams:
Open Source And Free
Developers like to avoid the cost incurred on procurement for code pipelines. They like to build code into a simple artifact or centralize the location for standardizing code deployments. Using Jenkins, developers tend to focus on the CI process effortlessly. It is because it is an open source automation server that runs on premises in a virtual environment or on the cloud in a VM.
Plugins And Integrations
Jenkins offers a rich ecosystem of plugins, that can be developed by anyone for anyone. These plugins are diverse and range from on premises to cloud. Therefore, if you use crucial cloud providers, you can integrate the deployment with Jenkins through its plugins.
Some of the top plugins a developer needs to be familiar with are:
Dashboard view: It enables you to view and monitor the status of all the CI tasks from the Jenkins dashboard. Build Pipeline Plugins: It allows you to view the jobs in a pipeline and define manual tasks and triggers that require intervention before any type of execution. Test Analysis Plugins: It is a group of plugins that are used to test code at the CI stage. The process is performed before deploying the code to development, staging, or production environments.
Hosting Options
Jenkins provides different setup options like on premises, cloud and containers to install and deploy the software. Moreover, since it can run on any OS, you can install the CI server regardless of the company’s system. Organizations can run Jenkins CI/CD on a cloud by downloading and deploying it on a VM. Furthermore, they can also run it on a Docker container to scale the CI tool using Kubernetes.
Community Support
Officially started in 2011, Jenkins constitutes a long history of operations for CI/CD tools. As an open source tool, it enables creators, community contributors and users to participate in its functionality, maintenance and roadmaps as an open source product. Jenkins is estimated to hold a community of more than 1,000,000 users and also operates nine special interest groups during the time of publication.
CI/CD Integrations
Jenkins allows software developers to work on other CI/CD pipelines. It means that it works alongside other platforms that a team uses for continuous delivery. It also enables a team to integrate CI and build a part of the pipeline with another tool. This way, they can build and store the application’s artifacts.
Follow this post to show you how to install how to Install Jenkins on Debian 11 Server (CI CD Open Source).
Before installing Jenkins, you will need to install the Java and other required dependencies on your server. You can install all of them by running the following command:
By default, Jenkins is not available in the Debian 11 default repository. So you will need to add the Jenkins repository to the APT. First, download and add the Jenkins GPG key with the following command:
curl -fsSL https://pkg.jenkins.io/debian/jenkins.io.key | tee /usr/share/keyrings/jenkins-keyring.asc
Next, add the Jenkins repository with the following command:
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian binary/ | tee /etc/apt/sources.list.d/jenkins.list
Once the Repository is added, update the repository and install the Jenkins with the following command:
apt-get update -y
apt-get install jenkins -y
After the successfull installation, verify the status of the Jenkins service using the following command:
systemctl status jenkins
You will get the following output:
● jenkins.service - Jenkins Continuous Integration Server
Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2022-04-22 06:24:08 UTC; 28s ago
Main PID: 6582 (java)
Tasks: 42 (limit: 2341)
Memory: 348.7M
CPU: 59.447s
CGroup: /system.slice/jenkins.service
└─6582 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080
Apr 22 06:23:28 debian jenkins[6582]: *************************************************************
Apr 22 06:23:28 debian jenkins[6582]: *************************************************************
Apr 22 06:23:28 debian jenkins[6582]: 2022-04-22 06:23:28.833+0000 [id=43] INFO hudson.model.AsyncPeriodicWork#lambda$doRun$1: >
Apr 22 06:23:28 debian jenkins[6582]: 2022-04-22 06:23:28.858+0000 [id=43] INFO hudson.util.Retrier#start: Attempt #1 to do the>
Apr 22 06:24:08 debian jenkins[6582]: 2022-04-22 06:24:08.273+0000 [id=29] INFO jenkins.InitReactorRunner$1#onAttained: Complet>
Apr 22 06:24:08 debian jenkins[6582]: 2022-04-22 06:24:08.296+0000 [id=22] INFO hudson.lifecycle.Lifecycle#onReady: Jenkins is >
Apr 22 06:24:08 debian systemd[1]: Started Jenkins Continuous Integration Server.
Apr 22 06:24:08 debian jenkins[6582]: 2022-04-22 06:24:08.565+0000 [id=43] INFO h.m.DownloadService$Downloadable#load: Obtained>
Apr 22 06:24:08 debian jenkins[6582]: 2022-04-22 06:24:08.566+0000 [id=43] INFO hudson.util.Retrier#start: Performed the action>
Apr 22 06:24:08 debian jenkins[6582]: 2022-04-22 06:24:08.576+0000 [id=43] INFO hudson.model.AsyncPeriodicWork#lambda$doRun$1: >
By default, Jenkins can be accessed via the 8080 port. So it is a good idea to configure Nginx server as a reverse proxy for Jenkins. So you can access it through port 80.
First, install the Nginx package by running the following command:
apt-get install nginx -y
Once the Nginx package is installed, create an Nginx virtual host configuration file using the following command:
nano /etc/nginx/conf.d/jenkins.conf
Add the following lines:
upstream jenkins {
keepalive 32; # keepalive connections
server 127.0.0.1:8080; # jenkins ip and port
}
# Required for Jenkins websocket agents
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
server_name jenkins.example.com;
# this is the jenkins web root directory
# (mentioned in the /etc/default/jenkins file)
root /var/run/jenkins/war/;
access_log /var/log/nginx/jenkins.access.log;
error_log /var/log/nginx/jenkins.error.log;
# pass through headers from Jenkins that Nginx considers invalid
ignore_invalid_headers off;
location ~ "^/static/[0-9a-fA-F]{8}\/(.*)$" {
# rewrite all static files into requests to the root
# E.g /static/12345678/css/something.css will become /css/something.css
rewrite "^/static/[0-9a-fA-F]{8}\/(.*)" /$1 last;
}
location /userContent {
# have nginx handle all the static requests to userContent folder
# note : This is the $JENKINS_HOME dir
root /var/lib/jenkins/;
if (!-f $request_filename){
# this file does not exist, might be a directory or a /**view** url
rewrite (.*) /$1 last;
break;
}
sendfile on;
}
location / {
sendfile off;
proxy_pass http://jenkins;
proxy_redirect default;
proxy_http_version 1.1;
# Required for Jenkins websocket agents
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_max_temp_file_size 0;
#this is the maximum upload size
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffering off;
proxy_request_buffering off; # Required for HTTP CLI commands
proxy_set_header Connection ""; # Clear for keepalive
}
}
Save and close the file then verify the Nginx for any configuration error using the following command:
nginx -t
If everything is fine, you will get the following output:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Finally, restart the Nginx service to apply the changes:
systemctl restart nginx
You can also check the status of the Nginx using the following command:
systemctl status nginx
You will get the following output:
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2022-04-22 06:27:47 UTC; 4s ago
Docs: man:nginx(8)
Process: 7373 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 7374 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 7375 (nginx)
Tasks: 2 (limit: 2341)
Memory: 2.5M
CPU: 45ms
CGroup: /system.slice/nginx.service
├─7375 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
└─7376 nginx: worker process
Apr 22 06:27:47 debian systemd[1]: Starting A high performance web server and a reverse proxy server...
Apr 22 06:27:47 debian systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
Apr 22 06:27:47 debian systemd[1]: Started A high performance web server and a reverse proxy server.
At this point, Nginx is installed and configured as a reverse proxy for Jenkins. You can now access the Jenkins web interface using the URL http://jenkins.example.com. You should see the Jenkins initial password screen:
Now, open your command line interface and retrieve the Jenkins password using the following command:
cat /var/lib/jenkins/secrets/initialAdminPassword
You will get the Jenkins password in the following output:
4f9415413bd44f81a909c9d98777f00e
Copy the above password, go to the web installation screen, paste it into the password field and click on the Continue button. You should see the Customize Jenkins screen:
Click on the Installsuggestedplugins. You should see the Jenkins admin user creation screen:
Provide your Jenkins admin username, password and click on the Save and Continue button. You should see the Jenkins Instance Configuration screen:
Provide your Jenkins URL and click on the Save and Finish button. You should see the following screen:
Now, click on the Start using Jenkins. You should see the Jenkins dashboard on the following screen:
How to Install Jenkins on Debian 11 Server Conclusion
Jenkins is an excellent CI/CD tool that is free to use. We can summarize that Jenkins has features that boost release agility by providing CI services. Plugins, extensibility and online community are another top features to consider with Jenkins. Consider Jenkins alternatives depending on your project needs. They are: GitLab, CircleCL, GitHub, Buddy or Apache Maven.
In this post, we explained how to install Jenkins on Debian 11 server. You can now host Jenkins in your development environment and speed up your development process.
I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.
00votes
Article Rating
Subscribe
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.
DisagreeAgree
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.