3 Ways to Install Jenkins on Ubuntu

Updated: February 3, 2024 By: Guest Contributor Post a comment

Introduction

Jenkins is a popular automation server that helps automate the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery. Ubuntu, being one of the leading Linux distributions, offers a stable and secure foundation for installing Jenkins. This guide covers several methods to install Jenkins on Ubuntu, each with its advantages and potential drawbacks.

Approach 1: Using the Official Jenkins Repository

Installing Jenkins via its official repository ensures you receive updates directly from the Jenkins project. This method allows for straightforward installation and updates.

  1. Update the package index: sudo apt update
  2. Install Java (Jenkins requires Java to run): sudo apt install openjdk-11-jdk
  3. Add the repository key to the system: wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
  4. Append the Debian package repository address to the server’s sources.list: echo "deb https://pkg.jenkins.io/debian-stable binary/" | sudo tee /etc/apt/sources.list.d/jenkins.list
  5. Update the package index again: sudo apt update
  6. Install Jenkins: sudo apt install jenkins

Notes: This method ensures that you are using an official and stable version of Jenkins. It’s relatively easy to set up but requires Java. Also, it allows easy future updates.

Approach 2: Using Docker

If your Ubuntu system has Docker installed, you can run Jenkins in a Docker container. This isolates Jenkins from the rest of your system and simplifies updates and scalability.

  1. Install Docker if it’s not already installed: sudo apt install docker.io
  2. Run Jenkins in Docker: sudo docker run -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts

Notes: Running Jenkins inside Docker is a great way to keep your environment clean and scalable. However, managing persistent data and advanced configurations might be more complex than a traditional installation.

Approach 3: Using Ubuntu Package Manager (APT)

Jenkins can be installed directly via Apt, Ubuntu’s package manager, though it might not always be the latest version.

  1. Update package index: sudo apt update
  2. Install Jenkins: sudo apt install jenkins

Notes: This is the easiest method but may not provide the latest version of Jenkins. It is suitable for those who prefer simplicity over having the newest features.

Conclusion

There are multiple ways to install Jenkins on Ubuntu, ranging from using the official repository, leveraging Docker for isolation and scalability, to the simplicity of APT. The best method depends on your specific needs, infrastructure, and whether you prioritize having the latest updates, system isolation, or ease of setup. Regardless of your choice, each method outlined provides a foundation for utilizing Jenkins as a powerful automaton tool in your development pipeline.