DEV Community

Cover image for How to Install Jenkins on Ubuntu 24.04 Step by Step
Dinesh Wijethunga
Dinesh Wijethunga

Posted on Originally published at dineshstack.com

How to Install Jenkins on Ubuntu 24.04 Step by Step

In this tutorial, I will show you step by step how to install Jenkins on Ubuntu 24.04 with a complete, production-tested command sequence — including the two traps that produce "Package 'jenkins' has no installation candidate", both of which I hit on a real server.

Step 0 — Add swap if you have none

Check first. A box with Swap: 0B will eventually OOM-kill Jenkins mid-build once your pipeline runs composer, npm and a database-backed test suite at once:

free -h   # if Swap shows 0B:
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile && sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
echo 'vm.swappiness=10' | sudo tee /etc/sysctl.d/99-swappiness.conf
sudo sysctl -p /etc/sysctl.d/99-swappiness.conf

swappiness=10 keeps swap as an emergency parachute, not a performance drag.

Step 1 — Java 21

sudo apt update
sudo apt install -y openjdk-21-jre
java -version   # openjdk 21.x

Step 2 — The repo, and the two traps

Trap #1: the keyrings directory doesn't exist. Every tutorial pipes the key with wget -O /etc/apt/keyrings/… — but wget -O does not create parent directories. On a fresh Ubuntu 24.04, /etc/apt/keyrings may not exist, wget silently writes nothing usable, and apt later reports no installation candidate. Create it explicitly:

sudo mkdir -p /etc/apt/keyrings

Trap #2: the signing key rotated. The widely-copied tutorials reference jenkins.io-2023.key. That key has been rotated — with it, apt update fails signature verification and the package is invisible. Use the current key:

sudo wget -O /etc/apt/keyrings/jenkins-keyring.asc \
    https://pkg.jenkins.io/debian-stable/jenkins.io-2026.key

echo "deb [signed-by=/etc/apt/keyrings/jenkins-keyring.asc]" \
    "https://pkg.jenkins.io/debian-stable binary/" | \
    sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null

If you're reading this later, check pkg.jenkins.io/debian-stable for the current key filename — rotation will happen again.

Step 3 — Install and verify

sudo apt update
apt-cache policy jenkins   # must show a candidate version — if not, revisit step 2
sudo apt install -y jenkins
sudo systemctl enable --now jenkins
systemctl status jenkins   # active (running)

Step 4 — The setup wizard, opinionated

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

Open http://your-server-ip:8080, paste the password, then:

  • Plugins: "Install suggested plugins" is fine. You specifically need: Git, GitHub, Pipeline, Credentials Binding, SSH Agent. Anything missing installs later in two clicks.
  • Create the admin user — don't keep running as the unlock account.
  • Instance URL: set it to the HTTPS subdomain you'll create in post #4 (e.g. https://jenkins.example.com/), not the bare IP.

One UI note that cost me ten minutes: in current Jenkins (2.5xx), the # of executors setting is no longer on the System page — it moved to Manage Jenkins → Nodes → Built-In Node → Configure. For a VPS that also serves production traffic, set executors to 1 so two pushes can't run two heavy builds simultaneously.

Verification checklist

systemctl is-active jenkins          # active
curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:8080  # 403 = up, auth required
free -h                              # swap present

Next in the series: right now Jenkins is exposed on :8080 over plain HTTP. Post #4 puts it behind nginx on its own HTTPS subdomain — and covers the wildcard-vhost mistake that briefly broke TLS on a production domain.


Originally published at dineshstack.com — read the full version with code samples and updates there.

Top comments (0)