How to install Jenkins on Ubuntu 18.04 in VirtualBox

Posted on Sun 05 April 2020

jenkins ubuntu devops virtualbox

This article will show you how to install Jenkins on Ubuntu Server 18.04 that you will get up and running in VirtualBox on your machine. I wrote this using a mac, but it should be the same on other operating systems.

VirtualBox is a virtualization tool that allows you to create multiple virtual machines and have them run on your computer. You can download it and install it directly from their website.

Preparing Ubuntu Install

Once you have that up and running, go and download the ISO for Ubuntu Server. For this demo I used version 18.04 LTS.

With the new machine created and selected, right click and chose Settings, then click on Storage. Select the Empty option under the IDE controller and then on the right side of the interface click on the disk icon, which will allow you to point it to the ISO you downloaded.

Go to the Network tab, and select Bridged Adapter. I like to use this option because it gives the new machine an IP address on the network, instead of just a local one. Click OK.

Now you can start the new Virtual machine.

Installing Ubuntu

Once the installation starts, you can move around using the tab key or arrow keys. I mostly left everything as default, unless noted otherwise.

When the installation is complete, select Reboot, then press Enter when asked to remove the install media.

You can login, using the credentials you setup earlier. First, you should apply all the available patches to your new system.

sudo apt update && sudo apt upgrade

Installing Jenkins

In order for Jenkins to work we will need to install Java.

sudo apt install -y openjdk-8-jre

Next we will add the Jenkins key to our system.

wget -q -O - | sudo apt key add -

Add source packages

sudo sh -c 'echo deb binary/ > /etc/apt/sources.list.d/jenkins.list'

Now we can run another update and install Jenkins

sudo apt update && sudo apt install jenkins

And now, just to make sure that Jenkins will restart when the system is rebooted:

sudo systemctl enable jenkins

Final setup

You can now get the IP of your new system using the following command:

ifconfig | grep inet

You can take your ip address and add :8080 at the end of it and paste it in the browser. That will bring up the Jenkins setup (ex:

To pass this first screen you will need the secret key that was created during the install, so back on the server you can get that key like so:

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

That’s all folks. You should have a brand new VM Ubuntu Server running Jenkins.