Let Subversion trigger your Hudson build job

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.

4 Comments

  • Marty
    October 1, 2009 - 09:12 | Permalink

    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

  • bfluri
    October 1, 2009 - 11:10 | Permalink

    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

  • Marty
    October 5, 2009 - 10:12 | Permalink

    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 ;-)

  • Alex
    March 17, 2011 - 12:39 | Permalink

    Any changes that occur during the quiet period will be captured in the build. After all, that is what the quiet period is for.

  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    *


    *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

    Bad Behavior has blocked 36 access attempts in the last 7 days.