Guides 11792 Published by

The article guides readers through adding Jenkins’ official repository to Ubuntu, installing a recent Java runtime like OpenJDK 17, and then pulling and configuring the Jenkins service with systemd. It explains how to start the server, enable it to run on boot, retrieve the initial admin password from a protected file, and complete the web based wizard that installs recommended plugins and creates an administrator account. Practical advice addresses common pitfalls such as firewall blocks on port 8080, Java version mismatches, and stale packages that can keep Jenkins from launching. The writer also shares a personal tweak about switching to the official repository to resolve plugin compatibility problems on older machines, ending with encouragement to explore pipelines and automate tests.



Installing and configuring Jenkins on Ubuntu

You’ll learn how to pull the latest Jenkins build straight from its own repository, hook up a proper Java runtime, get the service running right away, and finish with the admin‑password wizard that turns the server into a fully‑functional CI engine.

Prerequisites: What you need before you start
  • A fresh or existing Ubuntu 22.04+ machine (or WSL if that’s your playground).
  • Sudo privileges – Jenkins needs to write to /var/lib/jenkins and bind to port 8080.
  • Internet access for downloading packages.
Step 1: Add the official Jenkins repository
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'

The Ubuntu default repo ships an old Jenkins (1.647 or older). That version can’t run newer plugins and will leave you staring at a broken build queue. By pointing to the official source, you get the latest LTS release that stays in sync with the plugin ecosystem.

Step 2: Install OpenJDK 11 (or higher)
sudo apt update
sudo apt install -y openjdk-17-jdk

Jenkins is a Java application, and it insists on a recent JDK. A quick check:

java -version   # should show 17 or newer

If you already have Java installed from somewhere else, skip the install but still verify the version.

Step 3: Pull down Jenkins
sudo apt install jenkins

That one command does everything: downloads the package, resolves dependencies, and registers the service. If your machine is a little slow, you might want to watch the download progress; it’s a 70 MB file on a 10 Mbps line.

Step 4: Start Jenkins and enable auto‑start
sudo systemctl start jenkins
sudo systemctl enable jenkins

You can confirm the service is live with:

systemctl status jenkins

If you see “active (running)”, you’re good. If not, read the journal:

journalctl -u jenkins --since="5 minutes ago"
Step 5: Grab the initial admin password

Jenkins creates a random password on first launch and stores it in /var/lib/jenkins/secrets/initialAdminPassword. Get it with:

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

Copy that string. It’s only valid the first time you hit the web UI.

Step 6: Complete the web‑UI wizard

Open your browser to http://<your-server-ip>:8080.

1. Paste the admin password.

2. Let Jenkins install suggested plugins – if you’re on a server that will run heavy jobs, skip “Git” and “Maven Integration”; I’ve seen people get bogged down installing dozens of plugins they never touch.

3. Create your first admin user (or keep the default if you prefer).

That’s it: Jenkins is up, running, and ready to accept build jobs.

Common pitfalls and how to dodge them
  • Firewall blocking 8080 – sudo ufw allow 8080/tcp.
  • Java version mismatch – If you see “Could not find java.lang.Object”, Jenkins can’t start. Re‑install the JDK or set JAVA_HOME correctly.
  • Old packages lingering – Running apt update && apt upgrade after adding the repo ensures you’re on the LTS build, not a stale release.
Real‑world tweak I learned last month

When I first installed Jenkins on an older 64‑bit VM for a hobby project, the default Ubuntu repo gave me 1.646. The plugin I needed (the “Docker Pipeline” plugin) refused to load because it required Java 8 but bundled a version of Docker that only worked with newer Java. Switching to the official repo resolved both issues in under ten minutes.