Chris Mendez in For Developers, Tools for Software Engineers, Jenkins, VirtualBox

Installing Jenkins using VirtualBox and Vagrant

Jenkins is a server dedicated to automating and scheduling tasks. Many development teams use it to ensure that their apps are working by scheduling tasks, tests or any other kind of chore.

There are many ways to install Jenkins but this blog entry will focus on using VirtualBox and Vagrant.

As a Mac user, if you're wondering why this is better than simply installing Jenkins through Homebrew, it's not. Homebrew is great and here's a tutorial. The purpose of using VirtualBox and Vagrant is help create a production-ready system that will ultimately live in the cloud. Jenkins is usually run on an independent machine that is accessed 24 hours a day so it makes sense, to me, to start creating a system that is AWS-ready rather than on my local computer.

The instructions below will show you how to install Jenkins on Linux Debian that you can later re-create elsewhere.

Step 1 - Install VirtualBox and Vagrant Locally

  • VirtualBox is a tool for creating virtual machines on your local computer. It can do much more but for now, all we need is a machine to host Jenkins.

  • Vagrant is used to help you create (and re-create) a development environment. Think of it this way, VirtualBox allows you to make a virtual computer but Vagrant will help you configure your machine to serve a specific purpose.

Step 2 - Create a Config file

Vagrant works by first creating a configuration file. The file is titled Vagrantfile and it will explain that we're going to install jenkins . Open up Terminal and type:

vagrant init jenkins  

Step 3 - Modify Vagrantfile

Open up Vagrantfile and uncomment this line of code. This will allow us to use the Jenkins web interface for its configuration. "private_network", ip: ""  

Step 4 - Start downloading

Now that you've configured your Vagrantfile, it's time to start downloading.

vagrant up  

Step 5 - Log into your dev environment

Vagrant's ssh command will allow you to log into your newly installed development environment.

vagrant ssh  

Step 6 - Install Jenkins

Now that you've ssh'd into your dev environment, it's time to download jenkins. The easiest thing for us to do is simply follow the these instructions.

Installing Jenkins on Ubuntu Source

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

Advanced Package Tools apt-get is a package manager for Debian and all we're asking it to do is update.

sudo apt-get update && sudo apt-get upgrade  

Ask apt-get to install Jenkins.

sudo apt-get install -y jenkins  

Step 7 - Visit the Admin Portal

Visit to see how things look.

Step 8 - Log In

Open up jenkins.log to find the initial administrative password.

vi /var/log/jenkins/jenkins.log  

Step 9 - Install additional plugins

Congratulations! You've installed VirtualBox, Vagrant and Jenkins. All that's left is a few more Jenkins plugins.

Step 10 - Ta Da!

Now it's time to actually get started.