In this example we're going to install Jenkins on Ubuntu 14.04, do basic configurations and access it on Internet with ngrok. The ngrok will be running on host machine though, not in vagrant box. Visit official Jenkins, installing Jenkins on Ubuntu and ngrok pages for more information. Jenkins requires a web server installed on your system so we're going to use apache as the web server.

Apache server

I assume that you've already installed it and it is up an running. Mine is accessible via IP address. Make sure you can access it too via http://localhost or whatever it is set to.


Install JDK and JRE

You need to have a JDK and JRE installed. At the time of writing this post openjdk-7-jre and openjdk-7-jdk were suggested.

$ sudo apt-get install openjdk-7-jre
$ sudo apt-get install openjdk-7-jdk

Verify installation

$ java -version
java version "1.7.0_121"
OpenJDK Runtime Environment (IcedTea 2.6.8) (7u121-2.6.8-1ubuntu0.14.04.1)
OpenJDK 64-Bit Server VM (build 24.121-b00, mixed mode)



$ wget -q -O - | sudo apt-key add -
$ sudo sh -c 'echo deb binary/ > /etc/apt/sources.list.d/jenkins.list'
$ sudo apt-get update
$ sudo apt-get install jenkins

Verify installation

# Check jenkins status
$ sudo service jenkins status
Jenkins Continuous Integration Server is running with the pid 11444

# See default jenkins configuration
$ cat /etc/default/jenkins

Backup and Restore

Backing up everything about Jenkins is as simple as archiving /var/lib/jenkins directory as shown below.

$ sudo tar czf jenkins-backup-2016-11-27.tgz /var/lib/jenkins
tar: Removing leading '/' from member names
$ ls -la
total 76528
drwxr-xr-x 4 vagrant vagrant 4096 Nov 27 15:44 .
drwxr-xr-x 4 root root 4096 Nov 27 14:48 ..
-rw-r--r-- 1 vagrant vagrant 220 Apr 9 2014 .bash_logout
-rw-r--r-- 1 vagrant vagrant 3637 Apr 9 2014 .bashrc
drwx------ 2 vagrant vagrant 4096 Nov 27 14:48 .cache
-rw-r--r-- 1 root root 78334420 Nov 27 15:44 jenkins-backup-2016-11-27.tgz
-rw-r--r-- 1 vagrant vagrant 675 Apr 9 2014 .profile
drwx------ 2 vagrant vagrant 4096 Nov 27 14:48 .ssh

To restore, manually unzip and replace the contents of the /var/lib/jenkins directory from a back up file above.

Login to Jenkins GUI

To login, go to in your browser (use your own host name/IP). This will ask you to "Unlock Jenkins" so follow the on screen instructions to unlock it. After unlocking it, select "Suggested Plugins" option to install plugins. Ignore creating a new admin user and click "Continue as admin" button. You will be prompted "You've skipped creating an admin user. To log in, use the username: 'admin' and the administrator password you used to access the setup wizard." message to finish setup. As it says in the message, if you run $ sudo cat /var/lib/jenkins/secrets/initialAdminPassword, you'll see the password. When you click "Finish" button, you'll automatically be logged in to Jenkins and see "Welcome to Jenkins!" message.



We know that the Jenkins GUI is accessible via in our host machine but we're going to access it on Internet as well. To do this, we need to download and unzip ngrok in our host machine so go ahead and do it. Once unzipped (I unzipped it to my desktop), run it with command below.

Note: You can copy ngrok executable to your vagrant project's shared folder and run it with $ ./ngrok http 80 inside vagrant box as well rather than doing it in your host machine.

$ ./ngrok http -host-header=rewrite

ngrok by @inconshreveable (Ctrl+C to quit)

Session Status online
Version 2.1.18
Region United States (us)
Web Interface
Forwarding ->
Forwarding ->

Connections ttl opn rt1 rt5 p50 p90
16 0 0.00 0.01 5.03 12.85

As you can see above, you can access ngrok web interface via to see what goes on with your current tunnel. In this case we're interested in "Forwarding" section so if you visit or anywhere in the world, you'll be able access your Jenkins GUI which is what we wanted.