How To Install Jenkins on Ubuntu 22.04

ยท

2 min read

How To Install Jenkins on Ubuntu 22.04

๐Ÿš€ Introduction to Jenkins

Jenkins is an open-source automation server that facilitates the building, testing, and deployment of software projects. It supports the automation of any task that can be scripted and is widely used for continuous integration and continuous delivery (CI/CD) pipelines. In this guide, we'll walk through the process of setting up Jenkins on an Ubuntu EC2 instance.

Step 1: Checking Java Installation

Before installing Jenkins, it's essential to ensure that Java is installed on the server, as Jenkins is built on Java. Run the following commands:

sudo apt update
sudo apt install fontconfig openjdk-17-jre
java -version

This will update the package list, install Java, and verify the installation.

Step 2: Installing Jenkins

Now, let's install Jenkins. Use the following commands:

sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
  https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
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
sudo apt-get update
sudo apt-get install jenkins

This set of commands adds the Jenkins repository key, updates the package list, and installs Jenkins.

Step 3: Configuring Security Group on AWS

Ensure that your AWS EC2 instance allows traffic on port 8080. This can be done by adjusting the inbound rules in the security group associated with your instance. Allow incoming traffic on port 8080 to enable access to the Jenkins web interface.

Step 4: Starting and Checking Jenkins Service

Start the Jenkins service and check its status with the following commands:

sudo systemctl enable jenkins
sudo systemctl start jenkins
sudo systemctl status jenkins

Enabling Jenkins to start at boot ensures that the service runs automatically upon server restart.

Step 5: Unlocking Jenkins and Initial Setup

Access the Jenkins web interface using your server's public IP and port 8080. You will be prompted to unlock Jenkins by providing the initial administrator password.

Retrieve the password from either of the following locations:

/var/lib/jenkins/secrets/initialAdminPassword

Copy the password and paste it into the Jenkins web interface.

Step 6: Setting Up Jenkins Administrator

Follow the on-screen instructions to set up the initial Jenkins administrator. You will be prompted to provide a username, password, full name, and email address.

Conclusion

๐ŸŽ‰ Congratulations! You've successfully set up Jenkins on your Ubuntu EC2 instance. Jenkins is now ready to streamline your continuous integration and delivery processes, helping you automate and accelerate your software development lifecycle.

Did you find this article valuable?

Support SagarOps by becoming a sponsor. Any amount is appreciated!

ย