hosting a plugin with github tired of slow SVN repos? host your Hudson plugin with GitHub!
Hudson 1.372 sets sail Hudson 1.372 released with a couple enhancements
hosting a plugin with github tired of slow SVN repos? host your Hudson plugin with GitHub!
Hudson 1.372 sets sail Hudson 1.372 released with a couple enhancements
We all know that keeping important files in version control is critical, as it ensures problematic changes can be reverted and can serve as a backup mechanism as well. Code and resources are often kept in version control, but it can be easy to forget your continuous integration (CI) server itself! If a disk were to die or fall victim to a misplaced rm -rf, you could lose all the history and configuration associated with the jobs your CI server manages.
It’s pretty simple to create a repository, but it isn’t obvious which parts of your $HUDSON_HOME you’ll want to backup. You’ll also want to have some automation so new projects get added to the repository, and deleted ones get removed. Luckily we have a great tool to handle this: Hudson!
We have a Hudson job which runs nightly, performs the appropriate SVN commands, and checks in. The high-level overview of this job is basically:
svn add -q --parents *.xml jobs/*/config.xml users/*/config.xml userContent/*svn status | grep '!' | awk '{print $2;}' | xargs -r svn rmsvn ci --non-interactive --username=mrhudson -m "automated commit of Hudson configuration"
You’ll want to make sure to use the --non-interactive option for any automated svn operations, as this ensures Subversion won’t hang asking a question but instead fail immediately. You may also need to provide your password with the --password option.To make such a Hudson job, create a new job, tie it to the master (since this is where the configuration files are), set it to build periodically (we use “@midnight”), and add an “Execute shell” build step. Here’s the full script we use, to put into the build step:
cd /opt/hudson
svn add -q --parents .xml jobs//config.xml users//config.xml userContent/
echo -e "warnlogn.logn.tmpn.oldn.bakn.jarn.json" > myignores svn propset svn:ignore -F myignores . && rm myignores
echo -e "buildsnlastnnextn.txtn.lognworkspacencoberturanjavadocnhtmlreportsnncoverndoclinks" > myignores svn propset svn:ignore -F myignores jobs/ && rm myignores
svn status | grep '!' | awk '{print $2;}' | xargs -r svn rm
svn st && svn ci --non-interactive --username=mrhudson -m "automated commit of Hudson configuration" && svn st
You’ll notice this does some extra things like set the svn:ignores property to provide a relatively clean svn st which it shows before and after the commit for logging purposes. One thing this job doesn’t do is put the build results of your jobs in version control. Because historical build logs and artifacts will never change and are also potentially large, a periodic (daily or weekly) cp or rsync of the jobs directory will still give you restorability while keeping your repository lean.
Now you can sleep well at night knowing that your CI server is safe and sound. If you are doing a similar thing with Hudson or another CI system, let us know about your solution!
Editor's Note: Mike Rooney is a Software Engineer at Genius.com, provider of real-time marketing automation software connecting marketing and sales. You can read more posts from Mike and other Geniuses at eng.genius.com

Latest release (2010.08.27):