CruiseControl is dead, long live Hudson

We’ve been using Cruise Control as our continuous integration system for ages, but problems with Subversion checkouts finally drove us to try Hudson as an alternative.

It’s fantastic – configurable from the UI, it archives build logs as well as artifacts, it’s got console output in the browser, and so on. Why didn’t we switch earlier?!

Anyhow, only slight modification need to make the lava lamps work with Hudson.

The lamps are controlled by an IP power switch, with the 4 outlets turned on or off by hitting a url with some GET parameters (ok, it’s not RESTful, but come on..). A cron job fires invokes the script every minute with the “check” command to parse the RSS feed of latest build results from Hudson, and light the lights accordingly.

Cron also calls the “off” function after 5pm, to save the lamps from burning out overnight.

The script is something like this :

#!/bin/bash
check() {
        # check Hudson on localhost and switch on lamps accordingly
        FAILCOUNT=`wget -O - -o wget.log http://localhost:8080/rssLatest | grep FAIL | wc -l`
        PASSCOUNT=`wget -O - -o wget.log http://localhost:8080/rssLatest | grep SUCCESS | wc -l`
        if [ $FAILCOUNT != 0 ]; then
                echo  `date` " : BUILD HAS FAILED"
                fail
        elif [ $PASSCOUNT != 0 ]; then
                echo  `date` " : BUILD IS OK"
                pass
       fi
}
pass() {
        # switch outlet 1 on and 3 off
        wget http://ip-switch.local/Set.cmd?CMD=SetPower+P60=1+P62=0 -q --delete-after
}
fail() {
        # switch outlet 3 on and 1 off
        wget http://ip-switch.local/Set.cmd?CMD=SetPower+P60=0+P62=1 -q --delete-after
}
off() {
        # switch them all off and go home
        wget http://ip-switch.local/Set.cmd?CMD=SetPower+P60=0+P62=0 -q --delete-after
}
exit