Branching: do it like this and nobody gets hurt

by simpsonjulian on September 10, 2008


It’s a very simple pattern. Make a Continuous Integration build for the trunk and the release branches. Most projects don’t need anything more clever than this.

Share with the group:
  • Digg
  • del.icio.us
  • Facebook
  • DZone
  • LinkedIn
  • Slashdot
  • StumbleUpon

Related posts:

  1. Build Pattern: The Captive Build Tool Check your build tool into your version control system. Ideally...
  2. Continuous Integration 1920’s style Totally missed this in 2007. Thanks to Oscar Centeno for...

Related posts brought to you by Yet Another Related Posts Plugin.

{ 1 trackback }

2008 in posts — The Build Doctor
December 30, 2008 at 3:31 pm

{ 4 comments… read them below or add one }

1 Douglas Squirrel September 11, 2008 at 12:50 am

We’re at most one release ahead of production, so we just have HEAD and the immediately prior release to run tests on; one of our projects releases frequently enough that we don’t even have to branch it at all normally. The three projects share a server farm, with several CruiseControl instances running different types of tests for each in rotation, so we’ve just inserted the branches as new projects in the rotation.

Since changes to the branches are rare, other projects don’t often have to wait for the branches. Since changes are well-vetted, we don’t run branched code through all the steps in the build pipeline, just the ones that are most critical (we skip browser-compatibility tests for example, since we rarely make substantial HTML changes in branches).

2 Jon September 11, 2008 at 9:47 am

I totally agree! KISS rule goes a long way here.
I wrote a little bit of ant/shell to handle automatic svn tagging based on whether a build was run against trunk or a branch.

I can't post the antscript here (blogger paranoia!), but suffices to say it's pretty noddy. Just passes in the ${label} and ${checkoutdir} for the build.

The bash bit:
#!/bin/bash

# Expects to be called by the tag.xml antscript. Needs to be told the working copy it's tagging from and the label to tag with.

checkoutDir=$1
label=$2
svn_revision=`svn info ./${checkoutDir}|grep "Revision:"|awk '{print $2}'`
svn_url=`svn info ./${checkoutDir}|grep "URL:"|awk '{print $2}'`
echo ${svn_url} |grep trunk > /dev/null 2>&1
if [ $? -eq 0 ]
then
svn_tag_url=${svn_url/trunk/tags}/trunk/
else
svn_tag_url=${svn_url/branches/tags}
fi

echo "svn autotagging ${svn_url} at revision ${svn_revision} for build ${label}…"
svn copy -r ${svn_revision} ${svn_url}/ ${svn_tag_url}/${label}/ -m "cruise: Autotagging for build ${label}(Revision: ${svn_revision})."
echo "svn autotagging complete."

I'm sure there's a more elegant way to do it though :)

3 tea42 September 12, 2008 at 6:29 am

Branches? Unless its a transitional release (rc1, rc2, etc.) shouldn’t you be releasing tags?

4 Julian September 12, 2008 at 6:49 am

Douglas, Jon. Thanks for your comments. I think I want to do a longer post on this topic.

Tea42: Yes, tagging/labelling is necessary to identify the exact code that’s running in prod. But IMO you need a branch so you can only release production bugfixes and enhancements and not mainline development as well.

Leave a Comment

You can 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>

Previous post: Build and Release work in London, UK

Next post: Do you want control or visibility?