Sling Academy
Home/DevOps/3 Ways to Install Jenkins on Ubuntu

3 Ways to Install Jenkins on Ubuntu

Last updated: February 03, 2024

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.

Next Article: How to define a Jenkins pipeline: A practical guide

Previous Article: How to Install Jenkins on Mac

Series: Jenkins Tutorials

DevOps

You May Also Like

  • How to reset Ubuntu to factory settings (4 approaches)
  • Making GET requests with cURL: A practical guide (with examples)
  • Git: What is .DS_Store and should you ignore it?
  • NGINX underscores_in_headers: Explained with examples
  • How to use Jenkins CI with private GitHub repositories
  • Terraform: Understanding State and State Files (with Examples)
  • SHA1, SHA256, and SHA512 in Terraform: A Practical Guide
  • CSRF Protection in Jenkins: An In-depth Guide (with examples)
  • Terraform: How to Merge 2 Maps
  • Terraform: How to extract filename/extension from a path
  • JSON encoding/decoding in Terraform: Explained with examples
  • Sorting Lists in Terraform: A Practical Guide
  • Terraform: How to trigger a Lambda function on resource creation
  • How to use Terraform templates
  • Understanding terraform_remote_state data source: Explained with examples
  • Jenkins Authorization: A Practical Guide (with examples)
  • Solving Jenkins Pipeline NotSerializableException: groovy.json.internal.LazyMap
  • Understanding Artifacts in Jenkins: A Practical Guide (with examples)
  • Using Jenkins with AWS EC2 and S3: A Practical Guide