A number of people have been twittering recently about Hudson Helper, and the fact that it can't (yet) support http access to Hudson servers. (There's just no pleasing some people, eh David?)
UPDATE: David reports that Hudson Helper has worked with both http and https since day one. He invites direct feedback if you're having problems.
To help fill this gap, I'd like to detail some of the handy API features of Hudson I've discovered since I first started using it back in October, which cane be fetched via http (or https) in a browser or via a script.
For more on the APIs available to the Latest Successful, Stable, Failed, or in fact simply the Latest Build, see:
- /lastSuccessfulBuild/api/
- /lastStableBuild/api/
- /lastFailedBuild/api/
- /lastBuild/api/
Of course, should you want details on a specific build rather than the latest, you can replace the "last*Build" token with an actual build number.
Finally, because no post about APIs should be complete with out some script showing how to exploit that interface, here's a quick example of how to fetch the latest successful, and as yet unreleased Drools 5.1 runtime library zip for use in our JBoss Tools 3.1.0.M2 builds. In this example, we fetch the build number for the last successful build and compare it to a cached version. We also fetch and cache the latest SVN revision number (in a build.properties file) so that we can later fetch Drools sources from the same point in time as the precompiled Drools binaries in the zip. This guarantees we're building from trunk, but only a good build in trunk, skipping over any failed builds or intermediate states (partial commits).
#!/bin/bash
droolsSNAPSHOTnum=drools-SNAPSHOT-num.txt
droolsSNAPSHOTrev=drools-SNAPSHOT-rev.txt
droolsSNAPSHOTzip=drools-SNAPSHOT-bin.zip
droolsSNAPSHOTurl=http://jboss-hudson-server/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/drools-5.1.0.SNAPSHOT-bin.zip
buildNumOld=0; if [[ -f $droolsSNAPSHOTnum ]]; then buildNumOld=$(cat $droolsSNAPSHOTnum); fi
buildNumNew=$(wget -q --no-clobber -O - http://jboss-hudson-server/hudson/job/drools/lastSuccessfulBuild/buildNumber)
buildRevOld=0; if [[ -f $droolsSNAPSHOTrev ]]; then buildRevOld=$(cat $droolsSNAPSHOTrev); fi
buildRevNew=$(wget -q --no-clobber -O - http://jboss-hudson-server/hudson/job/drools/lastSuccessfulBuild/api/xml?xpath=//changeSet/revision/revision)
if [[ $buildNumNew -gt $buildNumOld ]]; then
# get: 27013; must change to 27013
echo $buildRevNew > $droolsSNAPSHOTrev;
sed -i "s#\|##g" $droolsSNAPSHOTrev
buildRevNew="$(cat $droolsSNAPSHOTrev)"; #echo "."$buildRevNew"."
# replace "defaultTag=trunk:\d+" with defaultTag=trunk:${buildRevNew} in build.properties
# defaultSvnUrl=http://anonsvn.jboss.org/repos/labs/labs/jbossrules
# defaultTag=trunk:27013
sed -i "s#defaultTag=trunk:\d\+#defaultTag=trunk:$buildRevNew#g" build.properties; # grep "defaultTag=trunk:" build.properties
echo $buildNumNew > $droolsSNAPSHOTnum;
echo "Download $droolsSNAPSHOTurl ..."
wget -q --no-clobber -O $droolsSNAPSHOTzip $droolsSNAPSHOTurl
# ...
fi
Oh, and BTW, if you're ever looking for the latest
hudson.war executable, it's
always here.