Step-by-Step Guide: Installing Jenkins on Ubuntu

Step-by-Step Guide: Installing Jenkins on Ubuntu

Introduction

Jenkins, an open-source automation server, is a powerful tool for automating tasks related to building, testing, and deploying software. This step-by-step guide will walk you through the process of installing Jenkins on an Ubuntu machine, enabling you to harness its capabilities for efficient and automated software development workflows.

Step 1: Update Package Lists

Start by updating the package lists on your Ubuntu system using the following commands:

sudo apt update -y
#sudo apt upgrade -y  # Optionally, upgrade existing packages

Step 2: Add Adoptium GPG Key and Repository

Next, add the Adoptium GPG key to your keyring and add the Adoptium repository to your package sources:

wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | tee /etc/apt/keyrings/adoptium.asc echo "deb [signed-by=/etc/apt/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list 
sudo apt update -y

Step 3: Install Adoptium JDK 17

Now, install Temurin (formerly Adoptium) JDK 17 using the following command:

sudo apt install temurin-17-jdk -y
/usr/bin/java --version  # Verify the installation

Step 4: Add Jenkins GPG Key and Repository

Add the Jenkins GPG key to your keyring and include the Jenkins repository in your package sources:

curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
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 -y

Step 5: Install Jenkins

Install Jenkins using the following command:

sudo apt-get install jenkins -y

Step 6: Start Jenkins Service

Start the Jenkins service using the systemctl command:

sudo systemctl start jenkins

Step 7: Check Jenkins Status

Verify that Jenkins is running successfully:

sudo systemctl status jenkins

Step 8: Configure Firewall

If you have a firewall enabled, you need to open the Jenkins default port (TCP 8080). Run the following commands:

sudo ufw allow 8080
sudo ufw reload

Step 9: Access Jenkins Web Interface

  1. Open your web browser and navigate to http://localhost:8080.

  2. Retrieve the Jenkins unlock key by accessing the Jenkins server's log file:

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

    Copy the provided key.

  3. Paste the unlock key into the Jenkins web interface and click "Continue."

  4. Customize your Jenkins installation by selecting either the suggested plugins or choosing specific plugins based on your requirements.

  5. Create an admin user by providing the necessary details.

  6. Click "Save and Finish" and then "Start using Jenkins."

Step 10: Jenkins Installation Completed

Congratulations! You have successfully installed Jenkins on your Ubuntu machine. You can now start creating jobs, automating builds, and optimizing your software development workflow with Jenkins.

Conclusion

Jenkins simplifies and automates the software development lifecycle, making it an invaluable tool for development teams. By following this step-by-step guide, you've set up Jenkins on your Ubuntu machine, laying the foundation for efficient and automated software delivery. Explore Jenkins' features and plugins to tailor them to your specific development needs. Happy automating!