Certified Jenkins Engineer

Jenkins Setup and Interface

Demo Jenkins Installation

In this guide, you’ll learn how to install the Jenkins LTS release on an Ubuntu VM, verify prerequisites, install Java 17, and complete the initial setup via the web interface. By following these steps, you’ll have a stable, secure Jenkins server ready for your CI/CD pipelines.

Table of Contents

  1. Choose a Jenkins Release
  2. System Prerequisites
  3. Add Jenkins APT Repository
  4. Install Jenkins
  5. Verify Jenkins Service
  6. Install Java 17
  7. Start Jenkins
  8. Retrieve Initial Admin Password
  9. Complete Setup Wizard
  10. References

1. Choose a Jenkins Release

Jenkins provides two main release lines:

Release TypeCharacteristicsRecommended For
LTSStability, security fixes over extended supportProduction environments
WeeklyLatest features and bug fixesTesting and early feature adoption

The image shows a webpage from Jenkins.io detailing download and deployment options for Jenkins, including Stable (LTS) and Weekly releases, along with instructions for downloading Jenkins.

Scroll to your platform on the Jenkins download page. You can select Docker, Kubernetes, Windows, or Debian/Ubuntu packages.

The image shows the Jenkins download page, offering different package options for various platforms like Docker, Kubernetes, and Windows. It includes versions 2.462.1 LTS and 2.472, with links for each platform.

For public-cloud deployments, you also have AWS, Azure, Google Cloud, Oracle Cloud, and others:

The image shows a webpage from Jenkins.io about deploying Jenkins in public cloud environments, featuring options for AWS, Azure, Google Cloud, Oracle Cloud, and Civo Kubernetes.

In this tutorial, we’ll proceed with Jenkins LTS on Ubuntu.

2. System Prerequisites

Our test VM specifications:

ResourceSpecification
RAM4 GB
CPU2 cores
OSUbuntu 20.04+

Refer to the Jenkins Linux prerequisites for full details.

The image shows a webpage from the Jenkins documentation, detailing prerequisites for installing Jenkins on Linux, including hardware and software requirements.

3. Add Jenkins APT Repository

Add the Jenkins GPG key and repository:

sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
  https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key

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

Update APT and install Jenkins:

sudo apt-get update
sudo apt-get install -y jenkins

4. Install Jenkins

During the installation, you should see output confirming the package download:

Get:10 https://pkg.jenkins.io/debian-stable binary/ Packages [27.6 kB]
Hit:11 http://archive.ubuntu.com/ubuntu focal InRelease
Fetched 409 kB in 3s (147 kB/s)
Reading package lists... Done
The following NEW packages will be installed:
  jenkins net-tools
0 upgraded, 2 newly installed, 0 to remove and 8 not upgraded.
Get:1 https://pkg.jenkins.io/debian-stable binary/ jenkins 2.462.1 [91.2 MB]

5. Verify Jenkins Service

Immediately check Jenkins status:

sudo systemctl status jenkins

If Java is missing, you’ll see a failure:

● jenkins.service - Jenkins Continuous Integration Server
   Active: failed (Result: exit-code)
…
jenkins[31418]: jenkins: failed to find a valid Java installation

Inspect logs for details:

sudo journalctl -u jenkins --no-pager
java -version
# Command 'java' not found

Warning

Jenkins requires a supported Java runtime to start. Installing or configuring Java is mandatory.

6. Install Java 17

Jenkins LTS supports Java 17 per the Java Support Policy.

The image shows a webpage from Jenkins' documentation detailing the Java Support Policy, including supported Java versions and their corresponding long-term support and weekly release versions.

Install OpenJDK 17 and fontconfig:

sudo apt update
sudo apt install -y openjdk-17-jre fontconfig
java -version

Expected output:

openjdk version "17.0.8" 2023-07-18
OpenJDK Runtime Environment (build 17.0.8+7-Debian-1deb12u1)
OpenJDK 64-Bit Server VM (build 17.0.8+7-Debian-1deb12u1, mixed mode)

7. Start Jenkins

Restart and check status:

sudo systemctl restart jenkins
sudo systemctl status jenkins

You should see:

● jenkins.service - Jenkins Continuous Integration Server
   Active: active (running) since Mon 2024-08-19 08:03:40 UTC; 10s ago
 Main PID: 34102 (java)
    CGroup: /system.slice/jenkins.service
           └─34102 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war ...

8. Retrieve Initial Admin Password

Find the initial admin password in the logs:

sudo journalctl -u jenkins | grep 'initialAdminPassword'

Or directly read the file:

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

Inspect the Jenkins home directory:

ls /var/lib/jenkins
# config.xml  plugins  secrets  updates  users  jobs  ...

9. Complete Setup Wizard

  1. Open http://<YOUR_VM_IP>:8080 in your browser.

  2. Unlock Jenkins with the admin password from /var/lib/jenkins/secrets/initialAdminPassword.

  3. Select Plugins

    • Choose Suggested Plugins or pick specific ones.

    The image shows a Jenkins setup wizard interface with options for selecting plugins related to organization, administration, and build features. The user can choose from various plugins to install. The image shows a Jenkins setup wizard interface, specifically the "Pipelines and Continuous Delivery" section, where various plugins related to pipelines are listed for selection. The image shows a Jenkins setup wizard interface with options for configuring plugins related to source code management, distributed builds, and user management and security. The interface includes checkboxes for selecting specific plugins to install.

  4. Choose Appearance
    Pick your UI theme (e.g., Dark Theme):

    The image shows a Jenkins setup wizard interface with options for configuring notifications, appearance, and languages. The "Dark Theme" option is selected under the Appearance section.

  5. Create First Admin User
    Fill in credentials:

    The image shows a web page for creating the first admin user in a setup wizard, with fields for username, password, full name, and email address.

  6. Configure Jenkins URL
    Confirm or edit the root URL, then Save and Finish:

    The image shows a Jenkins setup wizard screen for instance configuration, prompting the user to enter a Jenkins URL. There are options to "Save and Finish" or "Not now."

Once done, Jenkins will be ready to use. Start creating your first build pipeline!

10. References

Watch Video

Watch video content

Practice Lab

Practice lab

Previous
Jenkins Installation Options