Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This is a Vagrant file and a provisioning script to create a Debian-based Jenkins server, including Java, Ant and Tomcat. Also see "" below
if [ ! -f /usr/bin/svn ];
echo "-------- PROVISIONING SUBVERSION ------------"
echo "---------------------------------------------"
## Install subverison
apt-get update
apt-get -y install subversion
echo "CHECK - Subversion already installed"
if [ ! -f /usr/lib/jvm/java-7-oracle/bin/java ];
echo "-------- PROVISIONING JAVA ------------"
echo "---------------------------------------"
## Make java install non-interactive
## See
echo debconf shared/accepted-oracle-license-v1-1 select true | \
echo debconf shared/accepted-oracle-license-v1-1 seen true | \
## Install java 1.7
## See
echo "deb precise main" | tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src precise main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver --recv-keys EEA14886
apt-get update
apt-get -y install oracle-java7-installer
echo "CHECK - Java already installed"
if [ ! -f /etc/init.d/jenkins ];
echo "-------- PROVISIONING JENKINS ------------"
echo "------------------------------------------"
## Install Jenkins
# URL: http://localhost:6060
# Home: /var/lib/jenkins
# Start/Stop: /etc/init.d/jenkins
# Config: /etc/default/jenkins
# Jenkins log: /var/log/jenkins/jenkins.log
wget -q -O - | sudo apt-key add -
sh -c 'echo deb binary/ > /etc/apt/sources.list.d/jenkins.list'
apt-get update
apt-get -y install jenkins
# Move Jenkins to port 6060
sed -i 's/8080/6060/g' /etc/default/jenkins
/etc/init.d/jenkins restart
echo "CHECK - Jenkins already installed"
### Everything below this point is not stricly needed for Jenkins to work
if [ ! -f /etc/init.d/tomcat7 ];
echo "-------- PROVISIONING TOMCAT ------------"
echo "-----------------------------------------"
## Install Tomcat (port 8080)
# This gives us something to deploy builds into
# CATALINA_BASE=/var/lib/tomcat7
# CATALINE_HOME=/usr/share/tomcat7
export JAVA_HOME="/usr/lib/jvm/java-7-oracle"
apt-get -y install tomcat7
# Work around a bug in the default tomcat start script
sed -i 's/export JAVA_HOME/export JAVA_HOME=\"\/usr\/lib\/jvm\/java-7-oracle\"/g' /etc/init.d/tomcat7
/etc/init.d/tomcat7 stop
/etc/init.d/tomcat7 start
echo "CHECK - Tomcat already installed"
if [ ! -f /usr/local/lib/ant/apache-ant-1.9.4/bin/ant ];
echo "-------- PROVISIONING ANT ---------------"
echo "-----------------------------------------"
mkdir -p /usr/local/lib/ant
cd /usr/local/lib/ant
wget -q
tar xzf apache-ant-1.9.4-bin.tar.gz
rm apache-ant-1.9.4-bin.tar.gz
ln -s /usr/local/lib/ant/apache-ant-1.9.4/bin/ant /usr/local/bin/ant
echo "Ant installed"
echo "CHECK - Ant already installed"
echo "-------- PROVISIONING DONE ------------"
echo "-- Jenkins: http://localhost:6060 "
echo "-- Tomcat7: http://localhost:7070 "
echo "---------------------------------------"
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Every Vagrant virtual environment requires a box to build off of.
# Named boxes, like this one, don't need a URL, since the are looked up
# in the "vagrant cloud" ( = "chef/debian-7.4"
# Publish guest port 6060 on host port 6060 "forwarded_port", guest: 6060, host: 6060 "forwarded_port", guest: 8080, host: 7070
config.vm.provider "virtualbox" do |vb|
# # Don't boot with headless mode. Use for debugging
# vb.gui = true
# # Use VBoxManage to customize the VM. For example to change memory:
vb.customize ["modifyvm", :id, "--memory", "1024"]
# Provision the box using a shell script
# This script is copied into the box and then run
config.vm.provision :shell, :privileged => true, :path => ""

This comment has been minimized.

Copy link
Owner Author

@aweijnitz aweijnitz commented Jul 4, 2014

Using port forwarding, the following URLs will be exposed on the host system


This comment has been minimized.

Copy link

@greyfairer greyfairer commented Sep 30, 2015

Debian box no longer exists, and ant version is no longer available.

See: for a working version @ 30/09/2015.


This comment has been minimized.

Copy link

@blangus blangus commented Oct 3, 2016

I've got it working by changing Vagrantfile:12
from = "chef/debian-7.4"
to = "puphpet/debian75-x64"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment