Blog

28 Dec, 2008

Using Hudson to autobuild Maven2 project on Subversion (SVN) commit

Posted by: admin In: Linux| Programming

The last days I’ve been testing out Hudson (in between lots of good Christmas food of course). Hudson is “an extensible continous integration engine”. That’s fancy-talk for what I like to call a build engine. It’s able to get updates from your SVN server and build the Maven project while keeping track of tasks, unit-tests and a lot of fancy things. The whole thing is extensible through a set of plugins. Hudson is really simple to set up, just download a jar file and run java -jar hudson.jar. Configuration and plugin download / installation is done completely within the webinterface.

I wanted to know whether it was possible for Hudson to build the project each time someone commits to SVN. It turnes out that there is two possibilities, a) Hudson can poll your version control server or b) you can use subversion hooks to notify Hudson of commits. Since we don’t like polling we’re going for the push method! Ps! I assume that you’ve already configured Hudson to pull updates from your SVN server and build the project.

In your svn repository folder you’ll find a “hooks” folder containing a lot of .tmpl files. As you might have guessed we’re using post-commit.tmpl.  If you’re on Linux create a new file called “post-commit”, make it executable with chmod +x post-commit. Fire up your favourite browser and find the configuration interface for your project inside Hudson. Check the box saying “trigger builds remotely” and write your secret token in the text box. We’re going to need that token when we’re setting up our hook script.

It’s time to edit our post-commit file. I used something like this:

#!/bin/sh
wget -b http://your-hudson-url:8080/job/your-project-name/build?token=your-secret-token > /dev/null

Now after every commit subversion will execute this file and Hudson will build your project automaticly! :-)

No Responses to "Using Hudson to autobuild Maven2 project on Subversion (SVN) commit"

Comment Form