Banner

How to trigger a Hudson build on a Subversion commit

This article describes how to set up Subversion on Linux/OSX (where wget is available) to trigger a Hudson build on each commit.

There is a nice post that tells how to tweak Hudson to run a build triggered by a post-commit hook on your subversion server.

There is a problem, that arises if we have a Hudson deployment that is password-protected. Then wget just returns Unauthorized , because he is first diverted to the login page where he has to log in.

To get around this problem we need to create a Hudson USER identified by a PASSWORD . We may want to give this user limited permissions, e.g. build only.

Then the post-commit hook would look like the following (merge it into one line, no extra spaces):

  wget -b http://HUDSON_URL/job/JOB_NAME/j_acegi_security_check?j_username=
  USER\&j_password=PASSWORD\&from=%2Fhudson%2Fjob%2FJOB_NAME%2Fbuild%3Ftoken=
  my_automated_build > /dev/null

The hook also contains the default code of sending an email:

 /usr/share/subversion/hook-scripts/commit-email.pl \
  "$REPOS" "$REV" commit-watchers@example.org

You may want to comment it out.

(c) 2011, ,