Jenkins is an open-source automation server software for repetitive tasks in the Continuous Integration and Delivery (CI/CD) processes. It is written in Java and available as a Web Application Archive (WAR) file and Ubuntu package.
This short guide will help you install Jenkins on Ubuntu 22.04. We’ll also discuss post-installation steps for properly configuring Jenkins for automating your CI/CD pipeline.
Table of Content
Let’s start with a brief introduction to Jenkins.
What is Jenkins?
Jenkins is an open-source automation server that developers use to automate various activities in the continuous integration and continuous delivery (CI/CD) pipeline of software projects.
It is a popular tool for automating various activities at all stages of the software development lifecycle, from the initial code writing and testing to the final deployment of applications to live servers.
Key Jenkins Features and Functions
Jenkins offers the following features and capabilities for software development and deployment processes.
Build Automation
Jenkins is often used to automatically build software projects from source code repositories available on Git or Subversion. It can be configured to compile code, run various tests, and create executable files.
Support For Continuous Integration
Once developers commit changes to the version control system, Jenkins facilitates integration after testing. This helps identify and fix integration issues early in the development process.
Support For Continuous Deployment
In addition to the CI workflows, Jenkins can automate the deployment to various target environments.
Easy Extensibility
You can easily extend the core Jenkins functionality with plugins that introduce custom functionality to the platform.
Pipeline as Code
Pipeline as Code is another aspect of Jenkins’s automation capabilities. Developers can use domain-specific language (DSL) to define the build and deployment of pipelines.
Security
To protect sensitive build and deployment processes, Jenkins has multiple security features, including user authentication and role-based access control.
Also Read: How to Check Java Version Installed on Linux
Install Jenkins on Ubuntu 22.04
Now that you know how Jenkins adds value to an organization’s CI/CD processes, let’s go into the details of installing it on an Ubuntu machine.
Prerequisites
- A machine running Ubuntu 22.04 Jammy Jellyfish
- A user with administrator rights
- Access to a terminal window or command line.
Step #1: Install Java
Jenkins requires the Java Runtime Environment (JRE) for operation. We’ll use OpenJDK to set up the Java environment for this guide. The OpenJDK development kit includes JRE.
At the moment, Jenkins supports Java 8 and Java 11. Since you can install multiple Java versions on Ubuntu, we’ll show you how to install these versions. However, note that only one of these versions could be set as the default choice.
Start by checking if Java is already installed on the system.
# java -version
Since the result indicates that the test server doesn’t have Java, we will use OpenJDK to install it.
Update the system package repository with the following command:
# sudo apt update
Now, you can choose between Java 8 and Java 11. We’ll describe the process for both versions.
For installing OpenJDK 8, run the following command:
# sudo apt install openjdk-8-jdk -y
Alternatively, to install OpenJDK 11, run:
# sudo apt install openjdk-11-jdk -y
At this point, you have an active Java installation on your machine.
Step #2: Add the Jenkins Repository
Sometimes, the default Ubuntu repository might not contain the most recent Jenkins version. So, instead of installing Jenkins from the usual Ubuntu repository, we recommend using the project-maintained repository to get the most recent features and patches.
To add the Jenkins repository to the Ubuntu system, follow these steps.
First, import the GPG key to verify package integrity.
# curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
Note that this command doesn’t produce any status message.
Next, add the Jenkins repository and add the authentication key to the source list with the following command:
# 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
Note that you won’t see any command output in the terminal.
Step #3: Install Jenkins
Now, it’s time to install Jenkins on the Ubuntu machine.
Since we added the Jenkins repository to the system index in the previous step, we highly recommend updating the index with the following command:
# sudo apt update
Next, initiate Jenkins installation with the following command:
# sudo apt-get install Jenkins
Once the command finishes, use the following command to verify that Jenkins is properly installed and active:
# sudo systemctl status Jenkins
Jenkins is functional and available if you see the bright green entry with the label active (running).
Otherwise, use the following command to enable the service:
# sudo systemctl enable --now Jenkins
Step #4: Modify Firewall to Allow Jenkins
Now that Jenkins is up and running, you must modify the firewall rules to allow traffic to the appropriate service.
We assume the Ubuntu machine is protected by the default Uncomplicated Firewall (ufw). We’ll use the following command to allow traffic to port 8080:
#sudo ufw allow 8080
Verifying that the rule has been added and is active is essential when working with any firewall. For ufw, use the following command:
#sudo ufw status
If you use a different firewall, use its specific commands to open port 8080 and validate the changes.
Step #5: Post-Installation Jenkins Configuration
After the installation, carry out the following steps to finalize the configuration.
Start by opening the server’s IP address in a web browser. Usually, the address would be like this:
http://ip_address_or_domain:8080
Note that you’ll need to use the server’s actual IP address or domain name when connecting to Jenkins. For instance, if you installed Jenkins on the localhost, use the appropriate IP address (10.0.0.1) and port:
http://localhost:8080
The page loads and prompts you to unlock Jenkins by entering the requested password.
Launch the terminal and enter the following command:
#sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Copy the code, enter it in the designated field, and click Continue.
The process will prompt you to choose plugins. You can also see a list of recommended plugins. We recommend opting for this list now because you can install additional plugins later.
You can see the progress of the plugin installation on the next screen.
The final step is to create the first administrator user. After entering the login information for your Jenkins administrator, click Save and Continue.
Finally, enter the domain name or IP address you want to use with port 8080. It’s probably the same as what you typed into the browser address bar.
Click Save and Finish after entering the Jenkins URL.
Jenkins should be ready, and you can see the Jenkins dashboard by clicking Start using Jenkins.
Conclusion
Jenkins installation on Ubuntu 22.04 is a simple procedure that improves DevOps processes by offering a dependable CI/CD infrastructure. We went through the process of setting up Jenkins and post-installation configurations to get it up and running on your Ubuntu machine.
Are you prepared to use RedSwitches to boost your hosting experience? Experience our top-notch dedicated hosting services today and expand your global visibility. We help businesses like yours set up and maintain reliable, always available, and highly secure dedicated hosting infrastructure.
Look no further than our instant dedicated servers, available in various configurations, including 10Gbps dedicated servers and bare metal servers. We’re your trusted hosting partner, providing the right dedicated server for your needs.
FAQs
What is Jenkins, and why should I install it on Ubuntu 22.04?
Jenkins is an open-source automation server for setting up, deploying, and automating software development processes. You may set up a dependable CI/CD environment for your software projects by installing it on Ubuntu 22.04.
Is Ubuntu 22.04 the only version I can use for Jenkins installation?
While this guide is specific to Ubuntu 22.04, Jenkins can be installed on various Ubuntu versions. However, you might need to adjust some commands and configurations accordingly.
Does Jenkins installation require administrator rights?
Yes, you typically need administrative (sudo) privileges to install Jenkins and its dependencies on Ubuntu. This ensures you have the necessary permissions to make system-level changes.
Can a remote server be used to install Jenkins?
Yes, you can install Jenkins on a remote Ubuntu server. You might need to use SSH to connect to the server and carry out the installation procedures described in the manual.
What hardware does Jenkins need to work on Ubuntu 22.04?
Jenkins doesn’t have high system requirements. A typical Ubuntu 22.04 server with a reasonably fast CPU, sufficient RAM (2GB or more is recommended), and disk space should suffice.
How do I secure my Jenkins installation after the initial setup?
After installation, you should secure Jenkins by configuring access controls, setting up authentication, and regularly updating Jenkins and its plugins. Additionally, plugins for better safety are available.
Can I integrate Jenkins with version control systems like Git?
Yes, Jenkins offers a variety of plugins, including those for well-known VCSs like Git. You can combine Jenkins with your choice version control system to automate your build and deployment operations.
How can I fix typical problems that come up when installing Jenkins?
If you encounter problems during installation, you can refer to Jenkins logs for error messages, check system requirements, ensure network connectivity, and verify configurations. You can also seek help from the Jenkins community and forums.
Is Jenkins suitable for all types of software projects?
Jenkins is versatile and can be adapted to various project types and languages. It’s commonly used for web development, mobile app development, and more. However, depending on the demands of your project, the precise setup and plugins may change.
Is Jenkins the only option for CI/CD on Ubuntu 22.04?
You can choose from several CI/CD tools available, including CircleCI, Travis CI, and GitLab CI/CD. The tool you choose will rely on the requirements of your project and how well you are acquainted with its features.