Setting Up Jenkins on Ubuntu 22.04 for Automated Deployments

Introduction Jenkins is an open-source automation server that facilitates continuous integration and continuous delivery of software projects. Setting...


0

Introduction

Jenkins is an open-source automation server that facilitates continuous integration and continuous delivery of software projects. Setting Jenkins on Ubuntu 22.04 provides a reliable platform for automating your deployment processes. This guide will walk you through the comprehensive steps for setting up Jenkins on Ubuntu, ensuring optimal performance and security. Leveraging Jenkins on Ubuntu streamlines your development workflow by automating repetitive tasks, thus enhancing efficiency. By the end of this guide, you will be able to set up Jenkins on Ubuntu and configure it for automated deployments. Setting Jenkins on Ubuntu is a crucial step in modernizing your software development pipeline.

Prerequisites

To ensure a smooth setup, you will need the following:

  • An Ubuntu 22.04 server with root or sudo access
  • Java Development Kit (JDK) installed on the server
  • Internet access to download necessary packages

Having these prerequisites ensures you have the foundational components required for setting Jenkins on Ubuntu.

Step 1: Update System Packages

Before proceeding with the Jenkins setup, ensure your system packages are up-to-date. This enhances system stability and security.

sudo apt update && sudo apt upgrade -y

This command updates the package list and upgrades existing packages to the latest available versions.

Step 2: Install Java

Jenkins requires Java to run, so the next step is to install the OpenJDK package on your server.

sudo apt install openjdk-11-jdk -y

This installs the OpenJDK 11 package, which is compatible with the latest Jenkins versions for Ubuntu.

Step 3: Add Jenkins Repository

Next, add the Jenkins Debian repository to your system to download the latest Jenkins version.

wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'

These commands add the Jenkins repository key and the repository to your system sources to enable package installation.

Step 4: Install Jenkins

With the Jenkins repository added, proceed to install Jenkins.

sudo apt update
sudo apt install jenkins -y

This updates your package list and installs Jenkins on your Ubuntu server, making it ready for initial configuration.

Step 5: Start and Enable Jenkins Service

Activate the Jenkins service to start on boot and ensure it is running.

sudo systemctl start jenkins
sudo systemctl enable jenkins

These commands start the Jenkins service and enable it to start automatically upon server reboot.

Step 6: Configure Firewall

To access Jenkins through a web interface, configure your firewall to allow Jenkins traffic.

sudo ufw allow 8080

This command opens port 8080, enabling access to the Jenkins web interface, which is its default port.

Step 7: Access Jenkins Web Interface

Open your web browser and navigate to http://your_server_ip:8080 to access Jenkins. You will see the Jenkins unlock screen, prompting you for an initial admin password.

Step 8: Retrieve Initial Admin Password

To unlock Jenkins, you need the initial admin password stored on your server.

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

This command displays the initial admin password, which you enter into the Jenkins unlock screen to proceed.

Step 9: Install Suggested Plugins

After logging in, Jenkins will prompt you to install plugins. Choose “Install suggested plugins” for a baseline configuration. This option installs essential plugins that Jenkins recommends for basic functionality, streamlining the setup process.

Step 10: Create First Admin User

The next step is to create your first administrative user account for Jenkins. Fill out the requested user details on the setup screen to establish your admin account. This account will have full access to Jenkins configurations.

Step 11: Set Up Jenkins Instance

Finalize the initial setup by configuring your Jenkins instance settings.

By following these steps, you will have successfully set up Jenkins on Ubuntu, ready to automate and enhance your software development processes.


Like it? Share with your friends!

0

What's Your Reaction?

hate hate
0
hate
confused confused
0
confused
fail fail
0
fail
fun fun
0
fun
geeky geeky
0
geeky
love love
0
love
lol lol
0
lol
omg omg
0
omg
win win
0
win
Anoop Patel