Skip to content

Instantly share code, notes, and snippets.

@tizzo
Created November 12, 2012 17:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tizzo/4060801 to your computer and use it in GitHub Desktop.
Save tizzo/4060801 to your computer and use it in GitHub Desktop.
Jenkins Veewee Build Script
VERSION=`VBoxManage -v | sed 's/\(.*\)r\([0-9]*\)/\1/'`
if [ $RELEASE = "precise" ]; then
TEMPLATE="ubuntu-12.04.1-server-i386"
fi
if [ $RELEASE = "lucid" ]; then
TEMPLATE="ubuntu-10.04.4-server-i386"
fi
BOX_NAME="$RELEASE-vbox-$VERSION"
BOX_PATH="boxes/$RELEASE-vbox-$VERSION.box"
if [ `VBoxManage list runningvms | grep -c $BOX_NAME` -eq 1 ]; then
VBoxManage controlvm $BOX_NAME poweroff
fi
if [ `VBoxManage list vms | grep -c $BOX_NAME` -eq 1 ]; then
VBoxManage unregistervm $BOX_NAME --delete
fi
if [ `vagrant box list | grep -c $BOX_NAME` -eq 1 ]; then
vagrant box remove $BOX_NAME
fi
if [ -e $BOX_PATH ]; then
rm $BOX_PATH
fi
bundle install
bundle exec veewee vbox define $BOX_NAME $TEMPLATE
bundle exec veewee vbox build -n -a $BOX_NAME
VBoxManage controlvm $BOX_NAME poweroff
VBoxManage startvm $BOX_NAME -type headless
bundle exec veewee vbox validate $BOX_NAME
VBoxManage controlvm $BOX_NAME poweroff
vagrant package --base $BOX_NAME --output $BOX_PATH
vagrant box add $BOX_NAME $BOX_PATH
VBoxManage unregistervm $BOX_NAME --delete
@tizzo
Copy link
Author

tizzo commented Nov 13, 2012

This job download the ubuntu server install iso (if necessary), downloads the guest additions ISO (if necessary), creates a VM and runs all install steps, runs the VeeWee vagrant behavior tests to verify the VM, exports the VM to a vagrant .box file, destroys the vm used for authoring the base box and then imports the exported box into vagrant for later provisioning.

I wrote a blog post detailing this setup.

I run this as a an Execute shell step in a Jenkins build on my local mac with Jenkins running as my user and veewee checked out in the workspace for the job.

@tizzo
Copy link
Author

tizzo commented Nov 22, 2012

Added parameters to build lucid as well as precise.

@tizzo
Copy link
Author

tizzo commented Dec 6, 2012

Updated to allow multiple runs with the same release.

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