BuildDoctor

Build Doctor

Continuous Integration, Delivery and Devops Consulting

Contact Us

(+44) 207 183 0323
hello@build-doctor.com
@builddoctor

Get in touch!

Branching: do it like this and nobody gets hurt

Posted on by Julian Simpson

Branching: do it like this and nobody gets hurt
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.


About Julian Simpson

Founder and Editor of The Build Doctor. Drinks Flat Whites. View all posts by Julian Simpson →

5 Responses to Branching: do it like this and nobody gets hurt

Douglas Squirrel says: 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).

Jon says: 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 :)

Julian says: 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 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>

The Build Doctor Ltd, Suite 17189, Lower Ground Floor, 145-157 St John Street, London, EC1V 4PW

© Build Doctor 2007-2012