Explore Courses
course iconScrum AllianceCertified ScrumMaster (CSM) Certification
  • 16 Hours
Best seller
course iconScrum AllianceCertified Scrum Product Owner (CSPO) Certification
  • 16 Hours
Best seller
course iconScaled AgileLeading SAFe 6.0 Certification
  • 16 Hours
Trending
course iconScrum.orgProfessional Scrum Master (PSM) Certification
  • 16 Hours
course iconScaled AgileSAFe 6.0 Scrum Master (SSM) Certification
  • 16 Hours
course iconScaled Agile, Inc.Implementing SAFe 6.0 (SPC) Certification
  • 32 Hours
Recommended
course iconScaled Agile, Inc.SAFe 6.0 Release Train Engineer (RTE) Certification
  • 24 Hours
course iconScaled Agile, Inc.SAFe® 6.0 Product Owner/Product Manager (POPM)
  • 16 Hours
Trending
course iconKanban UniversityKMP I: Kanban System Design Course
  • 16 Hours
course iconIC AgileICP Agile Certified Coaching (ICP-ACC)
  • 24 Hours
course iconScrum.orgProfessional Scrum Product Owner I (PSPO I) Training
  • 16 Hours
course iconAgile Management Master's Program
  • 32 Hours
Trending
course iconAgile Excellence Master's Program
  • 32 Hours
Agile and ScrumScrum MasterProduct OwnerSAFe AgilistAgile CoachFull Stack Developer BootcampData Science BootcampCloud Masters BootcampReactNode JsKubernetesCertified Ethical HackingAWS Solutions Artchitct AssociateAzure Data Engineercourse iconPMIProject Management Professional (PMP) Certification
  • 36 Hours
Best seller
course iconAxelosPRINCE2 Foundation & Practitioner Certificationn
  • 32 Hours
course iconAxelosPRINCE2 Foundation Certification
  • 16 Hours
course iconAxelosPRINCE2 Practitioner Certification
  • 16 Hours
Change ManagementProject Management TechniquesCertified Associate in Project Management (CAPM) CertificationOracle Primavera P6 CertificationMicrosoft Projectcourse iconJob OrientedProject Management Master's Program
  • 45 Hours
Trending
course iconProject Management Master's Program
  • 45 Hours
Trending
PRINCE2 Practitioner CoursePRINCE2 Foundation CoursePMP® Exam PrepProject ManagerProgram Management ProfessionalPortfolio Management Professionalcourse iconAWSAWS Certified Solutions Architect - Associate
  • 32 Hours
Best seller
course iconAWSAWS Cloud Practitioner Certification
  • 32 Hours
course iconAWSAWS DevOps Certification
  • 24 Hours
course iconMicrosoftAzure Fundamentals Certification
  • 16 Hours
course iconMicrosoftAzure Administrator Certification
  • 24 Hours
Best seller
course iconMicrosoftAzure Data Engineer Certification
  • 45 Hours
Recommended
course iconMicrosoftAzure Solution Architect Certification
  • 32 Hours
course iconMicrosoftAzure Devops Certification
  • 40 Hours
course iconAWSSystems Operations on AWS Certification Training
  • 24 Hours
course iconAWSArchitecting on AWS
  • 32 Hours
course iconAWSDeveloping on AWS
  • 24 Hours
course iconJob OrientedAWS Cloud Architect Masters Program
  • 48 Hours
New
course iconCareer KickstarterCloud Engineer Bootcamp
  • 100 Hours
Trending
Cloud EngineerCloud ArchitectAWS Certified Developer Associate - Complete GuideAWS Certified DevOps EngineerAWS Certified Solutions Architect AssociateMicrosoft Certified Azure Data Engineer AssociateMicrosoft Azure Administrator (AZ-104) CourseAWS Certified SysOps Administrator AssociateMicrosoft Certified Azure Developer AssociateAWS Certified Cloud Practitionercourse iconAxelosITIL 4 Foundation Certification
  • 16 Hours
Best seller
course iconAxelosITIL Practitioner Certification
  • 16 Hours
course iconPeopleCertISO 14001 Foundation Certification
  • 16 Hours
course iconPeopleCertISO 20000 Certification
  • 16 Hours
course iconPeopleCertISO 27000 Foundation Certification
  • 24 Hours
course iconAxelosITIL 4 Specialist: Create, Deliver and Support Training
  • 24 Hours
course iconAxelosITIL 4 Specialist: Drive Stakeholder Value Training
  • 24 Hours
course iconAxelosITIL 4 Strategist Direct, Plan and Improve Training
  • 16 Hours
ITIL 4 Specialist: Create, Deliver and Support ExamITIL 4 Specialist: Drive Stakeholder Value (DSV) CourseITIL 4 Strategist: Direct, Plan, and ImproveITIL 4 Foundationcourse iconJob OrientedData Science Bootcamp
  • 6 Months
Trending
course iconJob OrientedData Engineer Bootcamp
  • 289 Hours
course iconJob OrientedData Analyst Bootcamp
  • 6 Months
course iconJob OrientedAI Engineer Bootcamp
  • 288 Hours
New
Data Science with PythonMachine Learning with PythonData Science with RMachine Learning with RPython for Data ScienceDeep Learning Certification TrainingNatural Language Processing (NLP)TensorflowSQL For Data Analyticscourse iconIIIT BangaloreExecutive PG Program in Data Science from IIIT-Bangalore
  • 12 Months
course iconMaryland UniversityExecutive PG Program in DS & ML
  • 12 Months
course iconMaryland UniversityCertificate Program in DS and BA
  • 31 Weeks
course iconIIIT BangaloreAdvanced Certificate Program in Data Science
  • 8+ Months
course iconLiverpool John Moores UniversityMaster of Science in ML and AI
  • 750+ Hours
course iconIIIT BangaloreExecutive PGP in ML and AI
  • 600+ Hours
Data ScientistData AnalystData EngineerAI EngineerData Analysis Using ExcelDeep Learning with Keras and TensorFlowDeployment of Machine Learning ModelsFundamentals of Reinforcement LearningIntroduction to Cutting-Edge AI with TransformersMachine Learning with PythonMaster Python: Advance Data Analysis with PythonMaths and Stats FoundationNatural Language Processing (NLP) with PythonPython for Data ScienceSQL for Data Analytics CoursesAI Advanced: Computer Vision for AI ProfessionalsMaster Applied Machine LearningMaster Time Series Forecasting Using Pythoncourse iconDevOps InstituteDevOps Foundation Certification
  • 16 Hours
Best seller
course iconCNCFCertified Kubernetes Administrator
  • 32 Hours
New
course iconDevops InstituteDevops Leader
  • 16 Hours
KubernetesDocker with KubernetesDockerJenkinsOpenstackAnsibleChefPuppetDevOps EngineerDevOps ExpertCI/CD with Jenkins XDevOps Using JenkinsCI-CD and DevOpsDocker & KubernetesDevOps Fundamentals Crash CourseMicrosoft Certified DevOps Engineer ExperteAnsible for Beginners: The Complete Crash CourseContainer Orchestration Using KubernetesContainerization Using DockerMaster Infrastructure Provisioning with Terraformcourse iconTableau Certification
  • 24 Hours
Recommended
course iconData Visualisation with Tableau Certification
  • 24 Hours
course iconMicrosoftMicrosoft Power BI Certification
  • 24 Hours
Best seller
course iconTIBCO Spotfire Training
  • 36 Hours
course iconData Visualization with QlikView Certification
  • 30 Hours
course iconSisense BI Certification
  • 16 Hours
Data Visualization Using Tableau TrainingData Analysis Using Excelcourse iconEC-CouncilCertified Ethical Hacker (CEH v12) Certification
  • 40 Hours
course iconISACACertified Information Systems Auditor (CISA) Certification
  • 22 Hours
course iconISACACertified Information Security Manager (CISM) Certification
  • 40 Hours
course icon(ISC)²Certified Information Systems Security Professional (CISSP)
  • 40 Hours
course icon(ISC)²Certified Cloud Security Professional (CCSP) Certification
  • 40 Hours
course iconCertified Information Privacy Professional - Europe (CIPP-E) Certification
  • 16 Hours
course iconISACACOBIT5 Foundation
  • 16 Hours
course iconPayment Card Industry Security Standards (PCI-DSS) Certification
  • 16 Hours
course iconIntroduction to Forensic
  • 40 Hours
course iconPurdue UniversityCybersecurity Certificate Program
  • 8 Months
CISSPcourse iconCareer KickstarterFull-Stack Developer Bootcamp
  • 6 Months
Best seller
course iconJob OrientedUI/UX Design Bootcamp
  • 3 Months
Best seller
course iconEnterprise RecommendedJava Full Stack Developer Bootcamp
  • 6 Months
course iconCareer KickstarterFront-End Development Bootcamp
  • 490+ Hours
course iconCareer AcceleratorBackend Development Bootcamp (Node JS)
  • 4 Months
ReactNode JSAngularJavascriptPHP and MySQLcourse iconPurdue UniversityCloud Back-End Development Certificate Program
  • 8 Months
course iconPurdue UniversityFull Stack Development Certificate Program
  • 9 Months
course iconIIIT BangaloreExecutive Post Graduate Program in Software Development - Specialisation in FSD
  • 13 Months
Angular TrainingBasics of Spring Core and MVCFront-End Development BootcampReact JS TrainingSpring Boot and Spring CloudMongoDB Developer Coursecourse iconBlockchain Professional Certification
  • 40 Hours
course iconBlockchain Solutions Architect Certification
  • 32 Hours
course iconBlockchain Security Engineer Certification
  • 32 Hours
course iconBlockchain Quality Engineer Certification
  • 24 Hours
course iconBlockchain 101 Certification
  • 5+ Hours
NFT Essentials 101: A Beginner's GuideIntroduction to DeFiPython CertificationAdvanced Python CourseR Programming LanguageAdvanced R CourseJavaJava Deep DiveScalaAdvanced ScalaC# TrainingMicrosoft .Net Frameworkcourse iconSalary Hike GuaranteedSoftware Engineer Interview Prep
  • 3 Months
Data Structures and Algorithms with JavaScriptData Structures and Algorithms with Java: The Practical GuideLinux Essentials for Developers: The Complete MasterclassMaster Git and GitHubMaster Java Programming LanguageProgramming Essentials for BeginnersComplete Python Programming CourseSoftware Engineering Fundamentals and Lifecycle (SEFLC) CourseTest-Driven Development for Java ProgrammersTypeScript: Beginner to Advanced

How to Install Jenkins on Ubuntu 22.04? [Step-by-Step Guide]

Updated on 17 May, 2021

17.78K+ views
11 min read

Automation is the key to the quick delivery of software versions that are not only speedier but also flawless and bug free in the dynamic world of software development. The foundation of this automation is made up of technologies that facilitate the creation, testing, and implementation of code changes. Jenkins is the ideal technology to help you expedite your efforts if you're trying to streamline your software development cycle through continuous integration and delivery.

With the help of this post, I will provide a thorough walkthrough of how to install Jenkins on Ubuntu 22.04, covering everything from configuration to the necessary prerequisites for a smooth Jenkins setup on Ubuntu. Explore Jenkins' features and see how they can improve your development process.

Step to Install Jenkins on Ubuntu Description
1. Update & Upgrade: Ensure your system is up-to-date: sudo apt update && sudo apt upgrade -y
2. Install Java: Install OpenJDK 11: sudo apt install openjdk-11-jdk -y
3. Update Package Lists: Update package lists to include the new repository: sudo apt update
4. Install Jenkins: Install Jenkins: sudo apt install jenkins -y
5. Start Jenkins: Start the Jenkins service: sudo systemctl start jenkins
6. (Optional) Configure Firewall: If needed, configure your firewall to allow access to the Jenkins port (default: 8080).
7. Access Jenkins: Open a web browser and navigate to http://localhost:8080 to complete the initial setup.

Prerequisites to Install Jenkins on Ubuntu 22.04

The following are required to installing Jenkins on Ubuntu 22.04, 

  • Make sure your Ubuntu 22.04 machine is up and running, to verify that you are running Ubuntu 22.04, type the command cat /etc/os-release 
  • Jenkins runs on Java, so make sure you have JDK 11 installed. 
  • Make sure your machine has package managed installed such as apt to easily manage software packages. 

A. Hardware Requirements: 

  • RAM- 4 GB (Recommended) 
  • Storage- more than 50 GB of Hard Disk Space (Recommended)        

B. Software Requirements: 

  • Java: Jenkins runs on Java, so make sure you have JDK 11 installed. 
  • Web Browser: Any browser such as Google Chrome, Mozilla Firefox, Microsoft Edge. 
  • Make sure your machine has package managed installed such as apt to easily manage software packages.  
  • Make sure your Ubuntu 22.04 machine is up and running, to verify that you are running Ubuntu 22.04, type the command cat /etc/os-release. For help in the planning of production capability of a Jenkins installation on Ubuntu see Choosing the right hardware for Masters

With these prerequisites in place, you will be ready to install Jenkins on your Ubuntu 22.04 machine. Elevate your skills with the KnowledgeHut DevOps Foundation Certification

How to Install Jenkins on Ubuntu?

Here is a step by step procedure on how to install Jenkins in Ubuntu 22.04:

Step 1: Update the System 

First, ensure that your package lists are up-to-date by running the following commands:

sudo apt update 
sudo apt upgrade

Step 2: Install Java 

For Java installation, we will use the version packaged with Ubuntu. To install the OpenJDK version of Java, begin by updating the apt package index:

Begin by updating the apt package index to ensure you fetch the latest information:

To check, please run the following command in the terminal:

  • Jenkins needs Java for running, but it doesn't include certain distributions by default, and Java versions of Jenkins are incompatible. 
  • Multiple Java implementations are available to you. OpenJDK is currently the most popular one, which we will use in this guide. 
  • Being an open-source Java application, Jenkins requires the installation of OpenJDK 8 on your system. The apt repositories can directly access OpenJDK 8. 
  • The installation of OpenJDK from standard repositories is recommended. Open and enter the following in the terminal window:
$ sudo apt update 
$ sudo apt install openjdk-8-jdk
  • The download and installation will be requested. Press the "Y" button and press the Enter button to finish the process. 
  • Java 8 will be installed on your system. We are ready to download Jenkins package now as we have our requirements ready! 

Step 3: Install Jenkins on Ubuntu

The default Ubuntu packages for Jenkins are always behind the current version of the project itself. You may use the project-maintained packages to install Jenkins to take advantage of the newest patches and features. 

1. Add the framework repository key:

$ wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add

The device returns OK when the key is inserted.

2. Next, link the repository of Debian packages to the sources.list of the server:

$ sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'

3. When both are in place, upgrade to apt to use the new repository:

$ sudo apt update 

4. Install Jenkins:

$ sudo apt install jenkins 

Now we're going to start the Jenkins server, as Jenkins and its dependencies are in place. 

Step 4: Start Jenkins 

1. You can start Jenkins using systemctl:

$ sudo systemctl start jenkins

2. As systemctl does not display performance, you can use the status command to check that Jenkins has successfully launched:

$ sudo systemctl status jenkins

If all went well, the start of the performance should demonstrate that the service is active and ready to boot: 

Output:

jenkins.service - LSB: Start Jenkins at boot time 
   Loaded: loaded (/etc/init.d/jenkins; generated) 
   Active: active (exited) since Sat 2021-04-17 00:34:17 IST; 26s ago 
     Docs: man:systemd-sysv-generator(8) 
  Process: 17609 ExecStart=/etc/init.d/jenkins start (code=exited, status=0/SUCC 

As Jenkins is running, so adjust the firewall rules to complete our further setup of Jenkins from the web browser. 

Step 5: Opening the Firewall 

1. Jenkins works by default on port 8080, so let's open the port with ufw:

$ sudo ufw allow 8080  

2. Check ufw’s status:

$ sudo ufw status 

You will see that traffic from anywhere is permitted to port 8080. 

Output:

Status: active 
To                         Action      From 
--                         ------      ---- 
8000                       ALLOW       Anywhere                   
CUPS                       ALLOW       Anywhere                   
27017                      ALLOW       Anywhere                   
27017                      ALLOW       192.168.1.10               
8080                       ALLOW       Anywhere                   
8000 (v6)                  ALLOW       Anywhere (v6)              
CUPS (v6)                  ALLOW       Anywhere (v6)              
27017 (v6)                 ALLOW       Anywhere (v6)              
8080 (v6)                  ALLOW       Anywhere (v6) 

3. If the firewall is inactive, the following commands will allow OpenSSH and turn it back on:

$ sudo ufw allow OpenSSH 
$ sudo ufw enable 

We can finish the initial configuration with Jenkins install in Ubuntu and our firewall configured. 

Note: If you decide to continue to use Jenkins, use a Nginx Reverse Proxy at Ubuntu 18.04 to configure Jenkins with SSL when your exploration has been completed to protect your passwords and any sensitive system or product information sent between the machine and the server in plain text. 

Step 6: Setting Up Jenkins 

1. To set up installation, visit Jenkins on its default 8080 port with your server domain name or IP address: http://your_server_ip_or_domain:8080 

You should see the Unlock Jenkins screen, which displays the initial password's location:

2. You can use the cat command to display the password:

$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword 

3. Copy the alphanumeric terminal 32-character password and paste into the Administrator Password field, then click Continue. 

Output:

0aaaf00d9afe48e5b7f2a494d1881326 

The following screen shows the ability to install or select certain plugins:

4. We will click on the option to install proposed plugins to start the installation process immediately. 

5. When the installation is done, the first administrative user will be prompted. You can save this step and use your initial password to continue as an Admin. However, we will take some time to create the user. 

The Jenkins default server is NOT encrypted to prevent data from being protected. Use the Nginx Reverse Proxy on Ubuntu 18.04 to configure Jenkins with SSL. This protects the information of users and builds transmitted through the web interface.

6. You will see a configuration instance page, which asks you to confirm your Jenkins instance's URL of choice. Confirm either your server's domain name or the IP address of your server.

7. Click Save and Finish once you have confirmed the relevant information. A confirmation page will show you that "Jenkins is ready!"

Hit Start using Jenkins button and it will take you to the Jenkins dashboard.

Congratulations! You have completed the installation of Jenkins. 

Step 7: Creation of New Build Jobs in Jenkins: 

The freestyle job is a highly versatile and user-friendly choice. It's easy to set up and many of its options appear in many other build jobs. For all projects, you can use it. 

Follow the following steps: 

1. You have to login to your Jenkins Dashboard by visiting

2. Create New item: 

Click on the New Item on the left-hand side of the dashboard.

3. Fill the project description: 

You can enter the job details as per your need.

4. Source Code Management: 

  • Under source code management, enter the repository URL.
  • You can also use a Local repository. 

5. Build Environment: 

Now in the Build section, 

  • Click on the “Add build Setup” 
  • Select "Execute Windows batch command".

Now, add the java commands. In this article, we have used javac HelloWorld.java and java HelloWorld.

6. Save the project: 

Click Apply and save the project. 

7. Build Source Code and check its status: 

Click on “Build Now” on the left-hand side of the screen to create the source code. 

8. Console Output: 

Select the build number and click on “Console Output” to check the status of the build run.

When it shows success, it means that we have successfully run the HelloWorld program from the cGitHub Repository. 

In case of failure, you can check the job logs by clicking on failure icon and debug the root cause.

How to Uninstall Jenkins? 

1. Initially, you need to stop the Jenkins service by executing the following command:

```sudo service jenkins stop``` 

2. Remove Jenkins using the following command:

```sudo apt-get remove --purge jenkins  -y ``` 

The -y flag automatically confirms the removal By following these two steps, you can uninstall Jenkins from your Ubuntu machine, ensuring a clean removal of the software. 

 Additionally, you can remove the Jenkins packages using the following command:

```sudo apt-get remove --auto-remove jenkins``` 

3. Now, verify the status of the Jenkins service with the following command:

``` service jenkins status``` 

For detailed guides on installing Jenkins on various platforms such as Windows, Linux, Mac, and more, explore our comprehensive article covering step-by-step instructions and prerequisites.

Why Use Jenkins?

You need to consider continuous integration (CI) and continuous delivery (CD) to understand Jenkins: 

  • Continuous integration: the practice of continuous production combined with the main industry. 
  • Continuous delivery: the code is constantly delivered to an area after the code is ready for delivery. It could be for production or staging. The commodity is supplied to a consumer base that can provide QA or inspection by customers. 

Developers update the code regularly in the shared repository (such as GitHub or TFS). Improvements made in the source code are made at the end of the day, making it difficult to identify the errors. So, Jenkins is used here.

Once a developer changes the repository, Jenkins will automatically enable the build and immediately warn you in the event of an error (Continuous Integration CI). 

Conclusion  

In this article, I walked through the step-by-step process of how to install Jenkins on Ubuntu 22.04, providing you with a thorough understanding. Additionally, we explored the uninstallation procedure, ensuring a complete coverage of managing Jenkins on your Ubuntu machine. By following this installation of Jenkins in Ubuntu - detailed step, you are well equipped with the knowledge to effortlessly set up and customize Jenkins according to your requirements. 

Whether you are a new or an experienced user, this article serves as a valuable resource to streamline the installation and removal processes, allowing you to tailor it to your needs on Ubuntu. If you're looking to deepen your DevOps knowledge, consider exploring the DevOps Foundation Certification offered by KnowledgeHut.

Frequently Asked Questions (FAQs)

1. Where does Jenkins install on Ubuntu?

Jenkins is commonly installed in the /var/lib/jenkins directory on Ubuntu, although alternative installation locations include /etc/jenkins and /usr/share/jenkins.

2. Are there any security considerations during Jenkins installation?

Yes, please make sure the following considerations are addressed when setting up Jenkins:

  • Make sure you set up strong passwords for Jenkins when setting it up.
  • Make sure you have firewall enabled and have only allowed access to port where Jenkins is listening.
  • Regularly update plugins to take advantage of available security patches.

3. How do I access the Jenkins web interface after installation?

Once installation is complete, you can access the Jenkins UI by opening a web browser and navigating to http://<your-server-ip>:8080. Make sure you replace your server ip with your server IP.

4. Can I install Jenkins on Ubuntu without root access?

Generally, installation with the package managed requires root access, but if you don't have root access, you might need to work with your admin to install Jenkins and request for necessary permissions. Some limited installations or configurations might be possible without root access, but it depends on the specific requirements and restrictions of your system.