views:

1533

answers:

5

Is there a better way to implement code freeze in SVN than asking all developers to not check in any new code?
We have CruiseControl running, which automatically deploys the latest build to environment. So if new code comes in, the build that was made available earlier changes to the latest one. I want that the build that is deployed is the one from a particular branch/tag, so that any new code check-ins dont affect the deployed build. Only when i tag/branch next time, the new code should be again deployed. How can we achieve this?

+13  A: 

Use SVN's built in branching functionality. The following link shows you all the details on how to branch (you can also use tags if you prefer): http://svnbook.red-bean.com/en/1.1/ch04.html

Stephane Grenier
Exactly. Just branch out the "frozen" revision as a Tag, then build/release the Tag copy instead of the Trunk copy.
icelava
Can CruiseControl be configured to build tag copy?
Akshay
@Akshay: It should be able to. Worse comes to worse, when you do a SVN checkout just grab the right branch.
Stephane Grenier
@Stephane As per my understanding, Cruise Control will look for any code changes, and as soon as any change happens, it will create a new build. So the earlier build will be lost. Is there any way Cruise Control can build on a branch/tag so that earlier build is the latest?
Akshay
Just make sure that CC is tagging each build. then you can obtain the exact configuration you want.
Charlie Martin
@Akshay: I concur with Charlie. As well, if you start to get into more complex builds and management you might want to look at more advanced automated builders. I've used Bamboo and Team City with great success. Not that CC is bad, it's just you might expand past it ;)
Stephane Grenier
+1  A: 

If you would rather be forceful, you can disable any commits via the pre-commit hook script. We have a few parked repos at work that we keep for historical reasons, thus no new commits are desired. This is how we have frozen these repos.


#!/bin/sh
exit 1

They can still be accessed and checked out but all new commits will fail. Thus in your case you could have a process that locks down the repo on a schedule for the build process.

notbenh
A: 

Of course there's also blocking at the access mechanism - tweaking the authz file for example.

John Stoneham
+1  A: 

Use a stable branch and Subversion >=1.5 (server, repository format and clients).

Make a branch from Trunk and designate it as your stable branch. Forbid your developers from committing to this branch, ideally using the authz file of whatever permissions are available to you.

Have a policy that ensures that any code changes get committed to Trunk before they can be deployed, even if these changes originated in a separate branch.

Have cruise control watch, build and deploy from the designated stable branch instead of trunk.

When it comes time to deploy the new software, use subversion's merge feature to merge into the branch from trunk. Always merge this way, only from trunk, and Merge tracking (version 1.5 and above only) will ensure that you can cherry pick and include just the changes you want from trunk, whilst excluding the things you don't want. It will also allow you to visually check exactly what revisions the current release includes and what is excluded.

Once you have merged and checked the results, committing the code will cause Cruise Control to publish - so publishing only happens at controlled points.

If you need to rollback to a previous version, create a tag from the required revision of your stable branch and temporarily point Cruise Control to that instead of your stable branch, when you've sorted out the problems on the stable branch, then you can deploy from the stable branch again, instead of the tag.

You may want to pro-actively make tags before problems occur, perhaps automatically using CruiseControl so that the tags are already in place if you need to switch around.

Do not do any development on the stable branch beyond fixing up merge conflicts, or merge changes from locations other than trunk - it will become very hard to tell exactly what's deployed.

Jim T
+1  A: 

The subversion convention for doing what you are talking about is creating a tag. Of course, a tag is no different than a branch in that it is just a copy of a certain development line at a certain revision (typically... there are complex tags). However, the subversion best practice is that tags are created once and are NEVER committed to - they are snapshots only.

So my advice would be to tag your build at the revision you want to freeze at, communicate to all of your developers that no commits are to be made to that tag (if they do not know it already), and build from that tag for your releases. Raise holy hell if someone commits to a tag.

whaley