Contents
Install Java.
Since Jenkins is a Java application, the first step is to install Java. Update the package index and install the Java 8 OpenJDK package with the following commands:
1 |
sudo apt updatesudo apt install openjdk-8-jdk |
Add Jenkins Repository
To start, first add Jenkins’s signing key and repository using the below commands:
1 |
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add - |
next, make a choice whether you wish to install stable or latest Jenkins server version:
1 2 3 4 |
FOR STABLE JENKINS VERSION RUN: sudo apt-add-repository "deb https://pkg.jenkins.io/debian-stable binary/" FOR LATEST JENKINS VERSION RUN: sudo apt-add-repository "deb http://pkg.jenkins-ci.org/debian binary/" |
Install Jenkins
Once the repository is included, all what remains to install Jenkins on Ubuntu 18.04 is to execute:
1 |
sudo apt-get install jenkins |
Adjusting Firewall
If you are installing Jenkins on a remote Ubuntu server that is protected by a firewall you’ll need to open port 8080
. Assuming you are using UFW
to manage your firewall, you can open the port with the following command:
1 |
sudo ufw allow 8080 |
Verify the change with:
1 |
sudo ufw status |
1 2 3 4 5 6 7 8 |
Status: active To Action From -- ------ ---- OpenSSH ALLOW Anywhere 8080 ALLOW Anywhere OpenSSH (v6) ALLOW Anywhere (v6) 8080 (v6) ALLOW Anywhere (v6) |
Setting Up Jenkin
To be able to login to the new Jenkins server installation first obtain an initial password:
To set up your installation, visit Jenkins on its default port, 8080
, using your server domain name or IP address: http://your_server_ip_or_domain:8080
You should see the Unlock Jenkins screen, which displays the location of the initial password:

1 |
$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword |
1 2 |
Output 4e99a203ee99548fae99548fa873 |
Copy the 32-character alphanumeric password from the terminal and paste it into the Administrator password field, then click Continue.
The next screen presents the option of installing suggested plugins or selecting specific plugins:

We’ll click the Install suggested plugins option, which will immediately begin the installation process:

Once the plugins are installed, you will be prompted to set up the first
admin user. Fill out all required information and click Save and Continue
.

Enter the name and password for your user:

Confirm the URL by clicking on the Save and Finish
button and the setup process will be completed, You will see a confirmation page confirming that “Jenkins is Ready!”:

Click Start using Jenkins to visit the main Jenkins dashboard:

At this point, you have completed a successful installation of Jenkins.