Skip to content
TutorialDevOps

How to Install Jenkins on Ubuntu 24.04 Step by Step

D

Dinesh Wijethunga

September 7, 2026 3 min readBeginner
ShareX / TwitterLinkedIn
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.

Frequently Asked Questions

Why does apt say "Package 'jenkins' has no installation candidate"?
Almost always a signing-key problem: either /etc/apt/keyrings didn't exist when you downloaded the key (wget -O does not create parent directories), or you used the rotated 2023 key. Download jenkins.io-2026.key and re-run apt update.
Which Java version does Jenkins need in 2026?
Java 17 or 21. On Ubuntu 24.04 install openjdk-21-jre — Jenkins drops older Java support aggressively.
Do I need swap for Jenkins?
If your VPS shows Swap: 0B, add a swapfile before installing. Jenkins + a big test suite + npm build can spike memory, and the OOM killer takes Jenkins down mid-build.
D
Dinesh Wijethunga

Senior Full Stack Developer · Building SaaS products & teaching Laravel/React · 10+ years experience · Founder of Orion360 · Based in Dubai, UAE.

Was this post helpful?

Add a comment

Comments

Guest comments are held for moderation.

You might also like

Deploy Laravel to a VPS with Laravel Forge: Complete Walkthrough
TutorialIntermediateDevOps

Deploy Laravel to a VPS with Laravel Forge: Complete Walkthrough

Laravel Forge isn't a host — it turns any VPS into a managed Laravel server. Full walkthrough: provisioning, GitHub push-to-deploy, the deploy script, one-click SSL, queue workers, the scheduler, and an honest look at zero-downtime options.

D
Dinesh Wijethunga
6 months ago
6m