How to install Jenkins on Ubuntu 18.04 Bionic Beaver

Installing jenkins on Ubuntu 18.04

The following tutorial will guide you through installing Jenkins on Ubuntu 18.04. The version of Jenkins available at the time of writing this tutorial required Java 8. I show you how to add the official Java repository to simplify installation and updates.

After the installation is complete, we’ll walk through running the initial configuration, including finding the randomly generated admin password and creating a new admin account.

Installing Java 8

If you just add the Jenkins repository and attempt an installation, Jenkins will fail to start. The reason is Jenkins will also install the default-jre package, which is based on Java 11 and is not compatible. Jenkins requires the official Java 8 release, so let’s install that first.

Add the official Java repository:

sudo add-apt-repository ppa:webupd8team/java

Unlike previous versions of Ubuntu, you do not have to run apt update.¬†The ‘update run’ command runs automatically after adding a repository.

Add the Jenkins Repository

Jenkins is not available in the official Ubuntu repositories. You will need to add Jenkins’ repository before being able to install it. A signing key is required to ensure all downloads (installs, patches) are from the official channel and have been unaltered in transit.

  1. Add the signing key for the Jenkins repository.
    wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
  2. To install stable releases of Jenkins, run the following command to add the stable repository.
    sudo apt-add-repository "deb https://pkg.jenkins.io/debian-stable binary/"
  3. To install the most recent releases, add the following repository instead.
    sudo apt-add-repository "deb http://pkg.jenkins-ci.org/debian binary/"

Install and Configure Jenkins

With Java 8 installed and the Jenkins repository added, we can now install and configure Jenkins on our Ubuntu server.

  1. Install Jenkins.
    sudo apt install jenkins
  2. Get the root password automatically generated during the installation.
    sudo cat /var/lib/jenkins/secrets/initialAdminPassword

    The password will look similar to the following:

    2943913774b646ebb82fad99729e97ff
  3. When installed, open a web browser and navigate to your server using port 8080. Enter the root password in the input field.

    Jenkins unlock screen
    Jenkins unlock screen

Jenkins is now installed and ready to use.