views:

52

answers:

1

My workplace uses Hudson for its daily builds, with several build slaves (one Linux, one Windows, one Mac) checking out our full codebase from svn and building our app at midnight each day. This all works fairly well.

There is an occasional problem that happens though... sometimes a developer will be working late, and will check in a change to svn just after midnight. When this occurs, it's possible that some of the daily build slaves will do their 'svn checkout' before the svn commit is processed, while other build slaves will do it after the commit is processed. When this happens, we end up with different revisions built on different platforms... e.g. the Mac build might a build of SVN revision 5555, while the Windows build ends up being a build of SVN revision 5556. That's bad, since we want all of the daily builds for a given day to be based on the same codebase.

I suppose one way to avoid this is to forbid developers to commit to svn between 11:30PM and 12:30AM, but I'd prefer a more elegant solution that doesn't rely on the developers behavior. Is there one? In particular, if there is a way to tell hudson to check out the revision of the code that was current at midnight of the current day (e.g. "svn co -r{"the-current-date"}") instead of checking out HEAD, I think that might do the trick.

Is there a common/easy way to handle this problem?

+3  A: 

The solution depends a little bit on how you start the builds. If they are all timer started, You can let them all start at the same time. The risk that you end up with different revisions will be minimal. A more elegant version is to have one job that triggers all your build jobs passing the revision as a parameter. If the build is not too long, you can build one job which than passes the revision on to all the other jobs.

EDIT: Currently the following is not supported by Hudson (1.376)

I also found a nice svn book. It states that you can replace the revision with a date in curly braces. So you can try <svn-url>@{00:00} in your job configuration.

Peter Schuetze
The @{00:00} trick is neat; Unfortunately it does not work via the java based svn client that is embedded within hudson. One other consideration is if your repository utilizes svn:externals then I believe the externals may be fetched with the wrong revision as well.
jdkoftinoff
I just noticed that too. :(
Peter Schuetze