2010/05/29

Fun with Javascript for Hudson

Right now, I do not have a lot of experience with Javascript but after having seen some funny stuff done to our internal Bugzilla with a userscript (templates for bugreports patched into the comment field), I decided to give it a try. Sometimes jobs in our internal internal build servers (Hudson) will break over night because of full hard drives e.g. So we created a special view with all failed builds and a Hudson extension to build all jobs in a view.

Now I thought this could be easily accomplished with Javascript as well, so I read a little bit about YUI2, which is included in Hudson already and came out with my first Javascript extension, which I host on Bitbucket.
The source code:

  • I just save the script in the userContent folder of Hudson and source it in the description of the view like this:
    <script src="/hudson/userContent/hudson_extensions/he-all.js" type="text/javascript"></script>.
  • First, I attach the initialization with the help of the YAHOO.util.Event.onDOMReady to the point in time when the whole page is rendered, on my first tries I only collected the links already rendered up to the point where the script was included.
  • If any job build links are found (isBuildHref), I render a Build All link.
  • When hitting the link, I just iterate over the links (buildAll) and send an asyncRequest discarding the result by not specifying a callback function at all to trigger the actual builds.
Now I already can think of other useful stuff to do with this :-).

No comments:

Post a Comment