Home > development infrastructure > Let Subversion trigger your Hudson build job

Let Subversion trigger your Hudson build job

September 3rd, 2009 bfluri Leave a comment Go to comments

The continuous integration server Hudson knows several ways to trigger a build. If you’d like Hudson to build your project when the source-base changes and you don’t want to let him poll your Subversion periodically let Subversion trigger the build upon commit. To do that, first, configure your job in Hudson (Job -> Configure -> Build Triggers) with “Trigger builds remotely (e.g., from scripts)” (”uDoo” is the job name, so replace it with your job name):

hudson_build_trigger

Second, configure a post-commit hook in your Subversion repository: In the repository directory of your Subversion-server, a directory hook exists. In this directory you may already have a file post-commit with 744 permissions. If not, a file post-commit.tmpl exists. In that case, copy the file and change the permissions:

$ cd path/to/your/repository/hook
$ cp post-commit.tmpl post-commit
$ chmod 744 post-commit

To trigger the build via Subversion, just put the following line at the end of the post-commit file.

wget -b http://HUDSON_URL/job/JOB_NAME/build?token=my_automated_build > /dev/null

That’s it.

  1. Marty
    October 1st, 2009 at 09:12 | #1

    Thanks for the post…

    two questions about it:

    1. the quiet period is still working then, right ? so if I set the period to be 3min then triggering the job via svn will still wait this 3min until the process starts ?

    2. If several svn changes happens nearly simultanously, it will still just start one build right ? So if two developers check in code in a close timeframe, what happens ? and is the next build then triggered only after the current build is done ?

    Would be great to know the answers :)

    Thanks
    Marty

  2. bfluri
    October 1st, 2009 at 11:10 | #2

    Marty,

    1. The quiet period should work. I only have 5 seconds configured but I see Hudson waiting that long until it processes the triggered build. This is also confirmed from the Hudson developer in the discussion: http://www.nabble.com/SVN-Post-commit-script-td23998756.html
    2. I don’t know. I never had this situation so far. Maybe you can simulate this scenario. If you do, please provide me the answer, I’m curious whether SVN or Hudson is handling concurrent commits.

    Cheers,
    –Beat

  3. Marty
    October 5th, 2009 at 10:12 | #3

    thanks for the answer.

    unfortunately I cant test the second approach as we dont have the situation up running. This was just a thought coming up my mind. Maybe someone else knows the answer ;-)

  1. No trackbacks yet.