How to install Jenkins on Ubuntu 20.04 Focal Fossa Linux

Jenkins is an automation server that is used to automate software development including: building, testing, and deploying as well as facilitating continuous integration and continuous delivery. The objective of this guide is to install Jenkins on Ubuntu 20.04 Focal Fossa Linux Server/Desktop.

In this tutorial you will learn:

  • How to add Jenkins’s signing key and repository
  • How to install Jenkins
  • How to retrieve the initial Jenkins password
  • How to login to Jenkins

Jenkins on Ubuntu 20.04 Focal Fossa Linux

Jenkins on Ubuntu 20.04 Focal Fossa Linux

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Installed Ubuntu 20.04 or upgraded Ubuntu 20.04 Focal Fossa
Software Jenkins
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to install Jenkins on Ubuntu 20.04 step by step instructions

  1. First step is to import Jenkins signing key and enable Jenkins repository. To do so open up your terminal and execute:
    $ wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
    $ sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
    $ sudo apt update
    
  2. Next step is to install an appropriate Java JDK version. Check the following Jenkins page for supported Java versions.

    Make a decision which Java version you would like to use and perform the installation before continuing. In this tutorial we will be using Java JDK 11. Amend the bellow command with your desired Java version number before execution:

    $ sudo apt install openjdk-11-jdk-headless
    


  3. Now we are ready to install Jenkins. To do so run:
    $ sudo apt install jenkins
    
  4. Enable Jenkins to start after reboot and start the service:
    $ sudo systemctl enable --now jenkins
    

    At this point the Jenkins server should be ready for incoming requests on port 8080. To confirm it run:

    $ ss -nl | grep 8080
    tcp   LISTEN 0      50          *:8080         *:* 
    
  5. Connect to the Jenkins server using your browser either from the local server http://localhost:8080 or remote machine http://SERVER-IP-OR-HOSTNAME:8080.

    When connecting remotely to a firewall enabled Jenkins server allow the 8080 port for incoming traffic:

    sudo ufw allow 8080 
    


  6. Retrieve initial Jenkins password. Example:
    $ sudo cat /var/lib/jenkins/secrets/initialAdminPassword
    8b5e143dfb694ea586bca53afe746a1e
    
    Enter the initial Jenkins password and hit continue

    Enter the initial Jenkins password and hit Continue.

  7. Select either to install suggested plugins and click on manual selection.

    Select either to install suggested plugins and click on manual selection.

  8. Wait for the installation to complete.

    Wait for the installation to complete.

  9. Create Jenkins administrator account

    Create Jenkins administrator account.

  10. Enter Jenkins server hostname

    Enter Jenkins server hostname.

  11. Jenkins installation is now complete

    Jenkins installation is now complete.



  12. Welcome to Jenkins administrator interface.

    Welcome to Jenkins administrator interface. All done.