How to Install Jenkins on Ubuntu

Share on Social Media

Don’t miss out on mastering automation! Learn how to install Jenkins on Ubuntu step-by-step—boost your DevOps skills, streamline your CI/CD pipelines, and stay ahead in tech. Start building smarter today! #centlinux #linux #devops



Introduction to Jenkins

What is Jenkins?

Jenkins is an open-source automation server that’s become a cornerstone in the DevOps world for its powerful ability to facilitate continuous integration and continuous delivery (CI/CD). Originally developed as the Hudson project by Kohsuke Kawaguchi in 2004 and later renamed Jenkins, this tool automates the parts of software development related to building, testing, and deploying, which helps developers detect issues early and deliver better software, faster.

If you’ve ever felt the pain of manually deploying code, running tests by hand, or coordinating builds across different environments, Jenkins is a lifesaver. It supports a vast ecosystem of plugins—more than 1,800—that extend its capabilities. From integrating with Git and Docker to managing deployment workflows with Kubernetes, Jenkins covers nearly every aspect of modern software delivery.

Jenkins is highly customizable, easy to set up, and suitable for both small startups and large enterprise-scale projects. With its web-based interface and built-in job configuration options, it simplifies complex automation tasks. Its popularity stems not just from functionality, but also from a vibrant community and frequent updates that keep it relevant in the fast-evolving tech world.

How to install Jenkins on Ubuntu
How to install Jenkins on Ubuntu

Why Use Jenkins for CI/CD?

The primary reason developers and companies adopt Jenkins is to streamline the CI/CD process, which is critical in modern agile development. Continuous Integration involves automatically testing and merging code changes regularly, which ensures that bugs are caught early and new features are integrated without causing unexpected failures.

Continuous Delivery or Deployment (the other half of CI/CD) is where Jenkins really shines—by automating the deployment of code to staging or production environments once it passes all tests. This reduces manual work, speeds up development cycles, and minimizes the risk of human error.

Here’s why Jenkins is often the first choice for CI/CD:

  • Free and Open Source: Jenkins is completely free, with no hidden costs.
  • Plugin Ecosystem: It supports integration with nearly every developer tool.
  • Community Support: Active forums, GitHub repos, and regular releases ensure you’re never alone when stuck.
  • Cross-Platform Compatibility: Jenkins runs on Windows, macOS, and all major Linux distributions.
  • Scalability: It supports distributed builds using master-agent architecture.

Whether you’re a solo developer wanting to automate deployments or a large team managing complex pipelines, Jenkins offers the flexibility and reliability you need.

Recommended Training: Jenkins: Jobs, Pipelines, CI/CD and DevOps for Beginners from Valentin Despa

5737068 3f88 3
show?id=oLRJ54lcVEg&bids=1597309

Prerequisites for Installing Jenkins on Ubuntu

System Requirements

Before installing Jenkins, it’s important to ensure that your system meets the basic requirements. Jenkins doesn’t need very high specs, but depending on your build size and the number of jobs, you might want more resources. Here’s a breakdown:

  • Operating System: Ubuntu 18.04, 20.04, or 22.04 (Jenkins supports Debian-based systems well)
  • Memory: Minimum 1 GB RAM (2 GB or more recommended for smooth performance)
  • Storage: At least 1 GB of free disk space (More if you store artifacts)
  • Processor: 1 GHz or faster CPU
  • Java: Jenkins requires Java (JDK 11 or newer)

It’s best to use a clean server environment to avoid package conflicts and ensure smoother setup. If you’re using a cloud instance (like AWS EC2 or DigitalOcean), start with a basic 2 GB instance and scale up later.

Read Also: How to install Jenkins on Rocky Linux 9

Preparing Your Ubuntu System

Begin by updating your Ubuntu packages to ensure you’re working with the latest versions:

sudo apt update
sudo apt upgrade -y

Next, install essential packages that might be required later in the installation process:

sudo apt install wget gnupg curl software-properties-common -y

Once your system is updated and equipped with the necessary tools, you’re ready to move on to Java installation, which is critical since Jenkins is a Java-based application.

Installing Java (JDK) on Ubuntu

Jenkins is a Java application, so the first essential step is to install the Java Development Kit (JDK). Jenkins officially supports Java 11 and newer versions, though Java 11 is most stable with current releases.

To install OpenJDK 11, use the following commands:

sudo apt install openjdk-11-jdk -y

After installation, confirm the installed Java version:

java -version

You should see an output like:

openjdk version "11.0.21" 2024-01-01

If the version prints correctly, Java is ready to go. You can now begin setting up the Jenkins repository.

Adding the Jenkins Repository

Importing the GPG Key

Before you can install Jenkins, you need to add its official repository to your system. This involves first importing the GPG key used to verify the packages. Run the following command:

curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null

This command securely downloads and installs the GPG key, ensuring the packages you install come from a trusted source.

Adding Jenkins Repository to Sources List

With the key installed, the next step is to add the Jenkins repository to your APT sources:

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

Now update your system again to include the new repository:

sudo apt update

At this point, Ubuntu knows where to fetch Jenkins from and you’re all set to install the software itself.

Install Jenkins on Ubuntu

Updating Package Index

Once you’ve added the Jenkins repository, it’s crucial to ensure that Ubuntu has the latest list of available packages from all enabled repositories:

sudo apt update

This guarantees that when you attempt to install Jenkins, your system will pull the latest available version from the official source.

Installing Jenkins via apt

To install Jenkins, just use this single command:

sudo apt install jenkins -y

The package manager will fetch Jenkins and all required dependencies and install them in one go. This may take a few minutes depending on your server speed.

Starting and Enabling Jenkins Service

Once installed, you need to start the Jenkins service and ensure it runs on boot:

sudo systemctl start jenkins
sudo systemctl enable jenkins

To confirm Jenkins is running properly, use:

sudo systemctl status jenkins

You should see something like:

jenkins.service - Jenkins Continuous Integration Server
Active: active (running)

If it’s active and running, you’ve successfully installed Jenkins on your Ubuntu server.


Adjusting the Firewall and Accessing Jenkins

Configuring UFW Firewall

By default, Jenkins listens on port 8080. If your server has a firewall enabled, especially if you’re using UFW (Uncomplicated Firewall) on Ubuntu, you’ll need to allow traffic on this port so Jenkins can be accessed from the browser.

To check if UFW is enabled, run:

sudo ufw status

If it’s active, enable access to port 8080 by running:

sudo ufw allow 8080

If you’re also using OpenSSH to manage your server remotely, make sure SSH access is still allowed:

sudo ufw allow OpenSSH

Now reload the firewall to apply changes:

sudo ufw reload

To verify the rules:

sudo ufw status

You should see output similar to:

8080                       ALLOW       Anywhere
OpenSSH                    ALLOW       Anywhere

This confirms Jenkins is now accessible externally.

Accessing Jenkins Web Interface

With Jenkins running and the firewall configured, you can access the Jenkins dashboard. Open your favorite web browser and go to:

http://<your-server-ip>:8080

For example, if your server IP is 192.168.1.100, you would navigate to:

http://192.168.1.100:8080

You’ll be greeted by the Jenkins setup screen, which asks for an Administrator password to unlock Jenkins for the first time. If you can see this page, congratulations—Jenkins is now live and accessible via the web!

Next up, let’s go through the initial setup process to unlock Jenkins and complete the configuration.


Initial Jenkins Setup

Retrieving Administrator Password

When Jenkins is first installed, it creates a default administrator password and stores it in a file on your server. You need to retrieve this password to unlock the Jenkins dashboard for the first time.

Use the following command to display the password:

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

You’ll see an alphanumeric password like this:

45dc7f54a4b04b3cae7d3d507f5f1d85

Copy this password and paste it into the Jenkins interface where it asks for the Administrator Password.

Once submitted, Jenkins will start guiding you through the rest of the setup process.

After entering the admin password, Jenkins will present you with two plugin installation options:

  • Install suggested plugins
  • Select plugins to install

For most users—especially beginners—it’s best to choose the Install suggested plugins option. This ensures that Jenkins installs the most commonly used plugins that support Git, build pipelines, SSH access, and more.

This installation process may take several minutes as Jenkins downloads and installs these components. Be patient and let it finish without refreshing the page.

Creating the First Admin User

Once the plugins are installed, Jenkins will prompt you to create your first admin user. Fill in the required fields:

  • Username
  • Password
  • Full Name
  • Email Address

Click Save and Continue to create the account.

Next, Jenkins will ask to confirm the instance URL, which should look like:

http://your-server-ip:8080/

Just confirm and save it.

Jenkins Dashboard
Jenkins Dashboard

That’s it—you’ll now land on the Jenkins Dashboard, ready to start configuring jobs and managing your CI/CD pipeline.


Configuring Jenkins for First Use

Basic Configuration Settings

Now that Jenkins is up and running, it’s time to tailor the settings to fit your development workflow. Start by exploring the Manage Jenkins section from the left-hand menu on the dashboard.

Here you’ll find a list of administrative options:

  • Global Tool Configuration – Set up default Java, Git, Maven, and Gradle paths.
  • System Configuration – Configure email notifications, environment variables, and more.
  • Security Settings – Control user access and permissions.

First, configure the basic tools:

  1. Click on Manage Jenkins > Global Tool Configuration.
  2. Under Git, make sure Jenkins can find your system’s Git binary. If not, manually enter /usr/bin/git.
  3. Under JDK, you can install a new JDK or point Jenkins to use the one installed system-wide.
  4. For Maven and Gradle, click “Add” if you plan to use those build tools.

Once this is done, Jenkins is ready to interact with your development tools.

Setting Up Your First Project

Let’s create your first Jenkins job:

  1. On the Jenkins Dashboard, click New Item.
  2. Give your project a name.
  3. Choose Freestyle project and click OK.

Now you’ll see a configuration page where you can:

  • Set a description
  • Add source code repositories (like GitHub)
  • Define build steps (e.g., shell scripts, invoking Maven)
  • Set post-build actions (like email notifications or archive artifacts)

Let’s say you want to clone a GitHub repo and print “Hello World”:

  • Under Source Code Management, select Git and paste your repo URL.
  • Under Build, click Add build step > Execute shell and type:
echo "Hello from Jenkins!"

Click Save, and then click Build Now.

You’ll see a build trigger in the sidebar. Click it, then click Console Output to see your job in action.

Installing Essential Plugins

Even though you installed recommended plugins earlier, you’ll likely need more depending on your use case. Go to:

Manage Jenkins > Plugin Manager > Available

Search and install popular plugins like:

  • GitHub Integration
  • Pipeline
  • Docker Pipeline
  • Slack Notification
  • Blue Ocean (modern UI for Jenkins)

After installation, Jenkins may prompt you to restart—do it to activate the new plugins.


Securing Your Jenkins Installation

Enabling HTTPS

Security is crucial, especially if your Jenkins instance is accessible over the internet. Setting up HTTPS protects your login credentials and job data.

To enable HTTPS:

  1. Obtain an SSL certificate. You can use Let’s Encrypt or buy one from a CA.
  2. Configure Jenkins to use HTTPS by editing the Jenkins default config file:
sudo nano /etc/default/jenkins

Change the HTTP port to 8443 or another secure port and add SSL options like:

--httpPort=-1 --httpsPort=8443 --httpsCertificate=/path/to/cert.pem --httpsPrivateKey=/path/to/key.pem

Restart Jenkins to apply changes:

sudo systemctl restart jenkins

Now access Jenkins securely via:

https://your-server-ip:8443

Managing User Permissions

By default, Jenkins may grant admin-level access to all authenticated users. This is dangerous, especially on multi-user systems.

To configure permissions:

  1. Go to Manage Jenkins > Configure Global Security
  2. Enable Matrix-based security
  3. Add user accounts and define roles (Admin, Read-only, Job configure, etc.)
  4. Remove anonymous read access unless you’re running an open system

You can also install plugins like Role-based Authorization Strategy to manage complex access scenarios across teams and jobs.


Troubleshooting Common Issues

Jenkins Service Not Starting

It’s not uncommon for the Jenkins service to fail during startup. If that happens, here’s what you can check:

  1. Check the status:
sudo systemctl status jenkins
  1. View logs for detailed errors:
sudo journalctl -u jenkins

Common causes of startup failures include:

  • Java not installed or wrong version: Jenkins needs Java 11 or newer. Confirm with java -version.
  • Port conflict: If another service is using port 8080, Jenkins won’t start. Check with sudo lsof -i:8080.
  • Permission issues: The Jenkins user may not have access to necessary directories.

Fix the underlying cause, then restart Jenkins:

sudo systemctl restart jenkins

Plugin Installation Failures

Sometimes, plugin installations fail due to network timeouts or compatibility issues. Here’s how to handle them:

  • Check the Plugin Manager > Installed tab for missing dependencies.
  • View plugin logs under /var/log/jenkins.
  • Try installing plugins manually:
    1. Download the .hpi file from Jenkins Plugin Index.
    2. Go to Manage Jenkins > Plugin Manager > Advanced.
    3. Upload the plugin file.

If plugins still fail, confirm your server has internet access and correct DNS settings. A proxy misconfiguration can also block plugin downloads.


Updating Jenkins

Checking for Updates

Keeping Jenkins updated ensures you get the latest features and security patches. To check for updates:

  1. Go to Manage Jenkins > Plugin Manager > Updates.
  2. Here, you’ll see updates available for Jenkins core and installed plugins.

Regularly check this page to avoid running outdated software.

Performing Manual Updates

To update Jenkins manually:

Download the latest .war file from the official Jenkins site and replace the old .war.

wget https://get.jenkins.io/war-stable/latest/jenkins.war
sudo mv jenkins.war /usr/share/jenkins/jenkins.war

Restart Jenkins service.

sudo systemctl restart jenkins

Your Jenkins will now be running the updated version. Always back up before updating to avoid data loss if anything goes wrong.

Recommended Training: DevOps Beginners to Advanced with Projects
Begin Your DevOps Career As a Newbie | AWS, Linux, Scripting, Jenkins, Ansible, GitOps, Docker, Kubernetes, & Terraform.

4039556 ebb3 9
show?id=oLRJ54lcVEg&bids=1597309

Integrating Jenkins with GitHub

Installing GitHub Plugin

To connect Jenkins with GitHub:

  1. Go to Plugin Manager and install:
    • GitHub
    • Git plugin
    • GitHub Branch Source
  2. Restart Jenkins after installation.

These plugins enable Jenkins to pull code from GitHub repositories and set up webhooks for automatic builds.

Creating a GitHub Webhook

To automate Jenkins builds when code is pushed:

  1. In Jenkins, create a new Freestyle or Pipeline job.
  2. In the job config, under Source Code Management, select Git and add your GitHub repo URL.
  3. Under Build Triggers, check GitHub hook trigger for GITScm polling.

Now go to your GitHub repo:

  1. Navigate to Settings > Webhooks.
  2. Add a new webhook:
    • Payload URL: http://your-jenkins-url/github-webhook/
    • Content type: application/json
    • Triggers: Push events

When you push new code to GitHub, Jenkins will automatically trigger a build.


Automating Builds with Jenkins

Configuring Build Triggers

Build triggers help Jenkins automatically start jobs without manual intervention. Popular trigger types include:

  • SCM Polling – Jenkins checks your Git repository periodically for changes.
  • Webhooks – GitHub or GitLab notifies Jenkins of changes.
  • Scheduled builds – Define a CRON-like schedule (e.g., nightly builds).

To configure:

  1. Go to a job’s configuration.
  2. Under Build Triggers, choose from:
    • Poll SCM (with a schedule like H/15 * * * * for every 15 mins)
    • GitHub hook trigger

This automation ensures a smooth CI/CD pipeline and reduces manual errors.

Setting Up Build Pipelines

To build advanced workflows, use Pipeline projects:

  1. Create a New Item > Pipeline.
  2. Under Pipeline, choose Pipeline script.
  3. Add your Jenkinsfile logic, for example:
pipeline {
    agent any
    stages {
        stage('Clone') {
            steps {
                git 'https://github.com/user/repo.git'
            }
        }
        stage('Build') {
            steps {
                sh 'make build'
            }
        }
        stage('Test') {
            steps {
                sh 'make test'
            }
        }
    }
}

This script automates everything from code checkout to testing and deployment. Pipelines can be expanded to include notifications, deployments to Kubernetes, Docker builds, and much more.


Frequently Asked Questions (FAQs)

Can Jenkins be installed on other Linux distributions?

Yes! Jenkins can be installed on Debian-based distros like Ubuntu, as well as RedHat-based systems like CentOS and Fedora. Instructions may vary slightly, especially regarding package managers.

What are the alternatives to Jenkins?

Some popular Jenkins alternatives include GitLab CI, CircleCI, Travis CI, Bamboo, and TeamCity. Each has its strengths, but Jenkins stands out for its extensibility and massive plugin library.

Is Jenkins free to use?

Absolutely. Jenkins is open-source and completely free to use, even in enterprise environments. However, some third-party plugins or integrations might have separate costs.

How can I backup Jenkins configurations?

You can back up Jenkins by copying the contents of /var/lib/jenkins/. This includes jobs, plugins, user configs, and credentials. Automate this backup regularly to avoid data loss.

Can I run Jenkins in a Docker container?

Yes, Jenkins has an official Docker image. It’s ideal for testing, temporary builds, or running isolated CI environments. You can spin it up using:

docker run -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts

Comprehensive Guide: How to run Jenkins in Docker Container


Conclusion

Jenkins is one of the most powerful tools in the DevOps toolkit, enabling developers to automate virtually every aspect of their build, test, and deployment processes. Installing Jenkins on Ubuntu is relatively straightforward, especially when broken into steps like setting up Java, adding repositories, installing the software, and configuring the firewall. But Jenkins doesn’t just stop at installation—it opens doors to a world of automation.

With plugins, pipeline support, and integrations like GitHub and Docker, Jenkins scales beautifully with your project’s needs. Whether you’re managing a small hobby project or deploying enterprise-grade applications, Jenkins can grow with you. And with a vibrant community backing it, you’ll never be left searching for support or new ideas.

By following the detailed guide above, you’re now equipped to not only install but also configure and customize Jenkins to suit your CI/CD goals. Now, go build something amazing!

Whether you need cloud optimization, server management, or automation, I provide comprehensive AWS and Linux services. Hire me on Fiverr to elevate your systems.


Looking for something?

Leave a Reply