Zero-touch deployment with Aegir and Jenkins

There's a newer version of this post- the post on this page is maintained for historical purposes only

Just a quick recap for those unfamiliar: I've been looking for a "zero-touch" development-staging-live workflow for Drupal, that would allow me to quickly roll out new Drupal platforms, and even migrate existing sites to those new platforms. I store all of my platform make files in a single Git repo, with branches like "live_platform1" and "dev_platform1". Ideally, I could commit a change to a makefile, and immediately my Aegir server would build a new platform based on that changed makefile and even migrate sites on the existing platform to the new platform.

mig5 has an excellent post describing a zero-touch workflow for Drupal- however, I needed to modify it a little to suit my needs. Note that this currently can build platforms, but not migrate sites.

First, I create a Jenkins project with a name that matches a branch in my repository, such as "dev_platform1". I use a similar configuration to the one described above, but with the following shell command:

/usr/local/bin/ ${JOB_NAME} dummyprofile dummywebserver dummydbserver ${WORKSPACE}/build.make ${JOB_NAME}_${BUILD_NUMBER} ${BUILD_NUMBER}

Of course, I needed to modify the and to take into account the new parameter, since I like to name my jobs something nicer than just a date string. Contact me if you want me to post a copy of those files.

Note that I also had to create an SSH key to allow the Jenkins user to log in as the Aegir user, and specify this key in using the env.key_filename parameter.

Then, I just needed to set up a Git post-receive hook to notify Jenkins of changes to a branch (platform):

while read oldrev newrev ref do branch=${ref##*/} echo "COMMAND: wget-q$branch/build" `wget -q$branch/build` done

To create a new platform, all I have to do is clone the existing Jenkins job, making sure to update the branch specifier, and create the corresponding Git branch.