views:

778

answers:

3

I'm looking for a way to trigger a Cruise Control.net build from a subversion post-commit hook.

I want this to in order start the build directly after an commit. I know about the normal way of doing this (polling the server) but it seems unnecessary to keep polling the server when it can be done using a hook.

One thought would be to invoke the "Force Build" functionality of the dashboard but this will trigger a build even if all modifications is outside of the trunk path tree and therefore no modification have been made which warrant a build.

A: 

Your idea of using the "Force Build" will probably work.

I don't understand your concern about modifications outside of the trunk path tree though? Can't you check for this in the post-commit hook and only force a build if the modified file is under /trunk

Have you considered the downside to doing this?

You have 2 changesets. You commit changeset 1, build starts, you commit changeset2 and have to wait for your build / test to complete before another build starts to build / test changeset 2.

Glen
(Fixed typo in comment)I have considered the downside, but my typical scenario (small team, relatively fast build) the upside would be greater. Aggregating builds makes it harder to know which revision broke a build.
FkYkko
+1  A: 

The problem with filtering changes is exactly why CC.NET uses the polling mechanism. (That, and the fact that there may be some scenarios where it is desirable to include new changes from multiple developers in the build.)

The "Force build" functionality is the only mechanism I can think of to accomplish this, however if you only wanted changes from the trunk that would require your post-commit hook to perform the equivalent of an svn log (possibly a verbose log) piped through some appropriate filter setting, then trigger the "force build" only if needed.

Richard J Foster
Actually, instead of 'svn log', svnlook will give you a list of only the files in the current commit. You can then grep the list for the string /trunk/. I do that in one of my post-commits.
james
A: 

I would recommend against doing this, but if you REALLY want to, I'd start with a URL trigger.

The URL trigger monitors any URL for changes, so you could just have your post commit hook update an html file. Alternatively, if you are using viewvc, you could have it monitor the following url:

http://servername/viewvc/repos?view=rev&revision=HEAD

That URL will get updated after every commit to SVN

consultutah
Using the URL trigger for this is basically the same as using the standard modification trigger. It is still a polling operation.Btw, I'm probably not going to do either.
FkYkko