BILLYSOFTACADEMY

Step by Step Guide to Installing Jenkins on Ubuntu 22.04

Installing Jenkins on Ubuntu 22.04 is a great way to get started with automation and continuous integration. In this blog post, we will walk through the steps of setting up Jenkins on an Ubuntu 22.04 server and how to use it for your projects. We’ll cover topics such as installing Java, configuring the firewall, downloading Jenkins packages, and setting up authentication for users. By the end of this blog post, you’ll have a working Jenkins instance running on your server!

Introduction: What is Jenkins and Why You Should Install it on Ubuntu 22.04

Jenkins is an open-source automation server that allows developers to easily create and manage continuous integration and continuous delivery (CI/CD) pipelines. It can be used to automate the process of building, testing, and deploying applications. Jenkins is highly extensible and has a wide variety of plugins available which makes it easy to integrate with various tools. Installing Jenkins on Ubuntu 22.04 provides an easy way to get started with CI/CD pipelines for any project. With its intuitive user interface, you can quickly set up automated jobs that will help you save time and effort in your development workflow. Additionally, the security features provided by Jenkins make it a great choice for organizations that need to ensure their data remains secure during the software development process.

Requirements

Below is a list of items that may be needed to complete this tutorial successfully:
1) A cloud-hosted instance or self-hosted server running Linux Ubuntu 20.04 LTS
2) A fully qualified domain name
3) A public static IP address
4) An SSH client such as Putty or the macOS terminal app

Overview

Below is an overview of the steps covered in this tutorial:
1) Open an SSH connection to the Ubuntu server and update the system repository
2) Install OpenJDK and install Jenkins
3) Configure your system firewall to allow Jenkins
4) Open the Jenkins dashboard and create a user.
5) Conclusion.

1. Open an SSH connection to the Ubuntu Server and update the system repository

The first step in completing this setup is to open an SSH connection to your Ubuntu server. If you are using a macOS device, open the terminal app and run the command below to connect to your server:

If your server is configured to authenticate using a key pair file, run the command below instead

If you use a Windows-based device, download and install the Putty SSH client. Open Putty and enter the IP address of your Ubuntu server on the IP address (or hostname field), ensure that Port is set to 22, and click Connect. Once you have connected to the server, run the command below to set a custom hostname

Edit the hosts configuration file for the server and add your custom hostname
To save changes made to the file, press CTRL + 0, press ENTER then press CTRL + X to exit the file. Run the command below to update the system repository

2. Install OpenJDK and install Jenkins

You have completed the basic server configuration and the next step is to install OpenJDK. Run the command below to install Java Development Kit version 11

Alternatively, you can install OpenJDK 8 with the command:

The version of Jenkins that is included in the official Ubuntu repository may not be the latest version. To get the latest version of Jenkins, run the command below to add the Jenkins repository

Add the Jenkins software repository to the sources.list.d directory and specify the authentication key

Update the system repository and install Jenkins
When the installation completes, run the command below to check if the Jenkins service is running. You should see a green entry labeled (active) running.
If the Jenkins service indicates that it is not running, run the command below to start the service

3. Configure your system firewall to allow Jenkins

The next step is to configure the Linux Ubuntu firewall to allow Jenkins. We assume that your server uses the uncomplicated firewall (ufw). By default Jenkins listens for connections on TCP port 8080. Run the command below to open the port:
If your server uses ConfigServer firewall, run the command below to open the configuration file
Scroll down to the TCP_IN section and add the port number 8080. Locate the TCP_OUT section and add the same port number. Press ctrl + O, press Enter, then press CTRL + X to save changes. Run the command below to apply the new firewall rules

4. Open the Jenkins dashboard and create a user

If you have reached this step, then you have successfully installed Jenkins. The next step is to access the Jenkins dashboard, complete the post-installation setup and create a user. Open a new browser window and navigate to https://your_server_ip_address_or_domain_name:8080. You will see a page Labeled Unlock Jenkins. You will also see a field that requires you to enter the Administrator password

But What is the password? Note that for security reasons, the default password for accessing Jenkins is stored in a log file named initialAdminPassword. Run the command below  to cat this file to reveal the password

Copy the password that you see, paste it into the Administrator password field, and click Continue.

The Customize Jenkins page will be displayed. Click Install Suggested Plugins which will automatically install the most important plugins for Jenkins. A getting started page will be displayed and show a progress bar indicating the installation progress.

When the installation complete, you will see a page for creating the first system admin user. Enter a username, email address and password on the fields provided then click Save and continue.

On the instance configuration page, enter the URL pointing to the server i.e https://your_domain_name_or_ip_address:8080 then click Save and finish. A message will be displayed notifying you that Jenkins is ready. Click the Start using Jenkins button to access the dashboard

Jenkins Frequently Asked Questions

Below are some frequently asked questions and answers about Jenkins. Hopefully these will answer some additional questions that you may have about Jenkins

What is Continuous Integration in Jenkins?

Continuous Integration (CI) is a development practice that enables developers to integrate code changes into a shared repository several times a day. Jenkins is an open-source automation server that can be used to automate the process of Continuous Integration. It can be used for building, testing, and deploying applications as well as automating other software development tasks. With Jenkins, developers can easily configure their CI pipeline and ensure that any change in the code is tested before being deployed. This helps reduce the risk of errors and improves the overall quality of the software product.

What is the difference between Hudson and Jenkins?

Hudson and Jenkins are two of the most popular continuous integration tools used in software development. While both tools are designed to help developers automate their build and deployment process, there are some key differences between them.

The main difference is that Hudson is an open-source project while Jenkins is a fork of Hudson. This means that while Jenkins has the same core features as Hudson, it also has additional features such as more plugins, better user interface and support for distributed builds. Additionally, Jenkins also has a larger user base than Hudson.

In terms of use cases, both tools can be used for automating builds and deployments on a wide range of platforms including Windows, Linux, Mac OS X and Solaris. However, due to its larger user base and additional features, Jenkins tends to be the preferred choice for many developers when it comes to automation tasks.

What is Groovy in Jenkins?

Groovy is a powerful scripting language used in Jenkins to automate tasks. It is an object-oriented programming language that helps developers create and maintain complex automation solutions. With Groovy, users can write custom scripts for Jenkins jobs, build pipelines, and manage cloud resources. It also provides an easy-to-use interface that allows developers to quickly develop and deploy applications without having to learn the underlying code. By leveraging Groovy’s capabilities, developers can build powerful automation solutions with minimal effort.

Which command is used to start Jenkins?

In order to start Jenkins, the command “java -jar jenkins.war” needs to be executed in the command prompt or terminal window. This command will start a local instance of Jenkins on your machine and you can then access it by opening your browser with the URL http://localhost:8080/.

What is Jenkinsfile?

Jenkinsfile is a text file that stores the configuration of a Jenkins pipeline and is used to define the steps of a continuous integration (CI) or continuous delivery (CD) process. It contains instructions for building, testing, deploying and other related tasks. This file can also be used to define parameters for certain stages of the CI/CD process such as environment variables, build triggers and notifications. With this file, developers can create automated pipelines with ease and ensure that their applications are continuously tested and deployed in an efficient manner.

Conclusion

At this point you have successfully installed Jenkins on a Linux Ubuntu 22.04 LTS server. Kindly refer to the Jenkins support page for details about managing and using Jenkins for various tasks.Click HERE to visit our Youtube channel or go to the home page to browser for more tutorials and guides. We hope that this tutorial has been informative and would like to thank you for reading it