Archive · DevOps

Installing Jenkins LTS on Ubuntu 22.04

Install Jenkins 2.387 LTS with Java 17 and do the first-run hardening.

1 min read

  • Jenkins 2.387 LTS
  • OpenJDK 17
  • Ubuntu 22.04 LTS

The 2.387 LTS line is current, and it runs on Java 11 or Java 17. Use Java 17 for new installs.

sudo apt update && sudo apt install -y openjdk-17-jre fontconfig
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
  /usr/share/keyrings/jenkins-keyring.asc > /dev/null
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
sudo apt update && sudo apt install -y jenkins
sudo systemctl enable --now jenkins
sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Open port 8080, finish the setup wizard and install the suggested plugins.

First hardening steps:

  • Put Jenkins behind nginx with TLS and set the Jenkins URL.
  • Use Security, Matrix-based authorisation (or your SSO) and disable anonymous access.
  • Set the controller to 0 executors and run builds on agents.
  • Schedule backups of /var/lib/jenkins.

Prefer the LTS repository over weekly releases for servers.