views:

108

answers:

1

I'm trying to figure out how to write a pre-commit hook for Git that checks the status of my Hudson build. If the previous build failed, it should disallow anyone from committing without first writing a specific line, e.g. "fixed build."

EDIT:

The first answerer has provided one side of the coin: the Hudson API.

I now need the other side. How do I write the pre-commit hook in Git?

+1  A: 

As mentioned in this blog post, Hudson has a discoverable API, through its Remote Access API.

http://myhudson.example.com/job/MyJob/api

By using a combination of:

  • wget (available on Unix or Windows)
  • parsing

you can extract the status of the latest build.

VonC
Very nice is Hudson's support for XPath. I used it to query the artifact Names to download specific artifacts in a second step. In you case a single wget call should give you the right information.
Peter Schuetze
Thanks for this. I've edited my question to now reflect that I'm only looking for how to write the pre-commit hook in `Git` now. Feel free to edit your answer.
Josh Smith