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.
Datum | Example |
---|---|
Latest Successful build number | buildNumber |
Latest Successful zip (published artifact) | GEF-Update-*.zip |
All checked out Project Set Files (Hudson workspace) | *.psf |
XML Digest of Latest Stable Build | lastStableBuild/api/xml |
SVN revision used for Latest Stable Build | //changeSet/revision/revision |
For more on the APIs available to the Latest Successful, Stable, Failed, or in fact simply the Latest Build, see:
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:Oh, and BTW, if you're ever looking for the latest hudson.war executable, it's always here.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
5 comments:
Hudson Helper has supported https since day 1. Some are even using self-signed certificates (more detail here).
If anyone is having troubles they should contact me directly.
Thanks, I've updated the post. Oh, and I meant there were people having problems with https, not http. Oops.
Anyway, I kinda wish I had an iPhone to test this out... or that there was a BlackBerry app equivalent.
Thanks for correcting the post! Or how about Android?
[All checked out Project Set Files (Hudson workspace) *.psf]
I realise this was a while back, but was wondering:
Did you just check out psf files or did you actually get Hudson to checkout all the modules mentioned in the psf files? If the latter, did you use a script or am I missing a plugin?
Thanks!
@Sagar: Not sure I understand your question. Hudson doesn't fetch from .psf, only Eclipse does that. Hudson uses map files... well, Hudson runs ant or shell, which launches headless Eclipse, which runs PDE, which fetches sources using map files.
PSFs are just a convenience so that you can get Eclipse to fetch the equivalent stuff in the map into your workspace.
Also, you can generate a map from what's in your workspace, then a psf from the map. The build.steps for this are dir2svnmap, dir2cvsmap, and map2psf. See line 151 of org.eclipse.dash.common.releng/buildAll.xml for detailed usage.
Post a Comment