2
votes

We are using TFS2010 for source control and TeamCity 8.x for CI. In our project we have Main branch for releases and bug-fixes and Dev for most of the development. Build steps for both branches are identical. and we have a few build configurations to go through:

List of build configurations

I can't seem to make TeamCity to do checkout on a single branch and run build only on the branch that was checked-in to.

First attempt: I've added a VCS Root to point to $/Root that contains both Main and Dev branches and created checkout rules:

Checkout rules

First checkin to Main works fine. Checkin to Dev after fails like this:

Build Failed to start

where DoNotExportAttribute is the file that was modified in the Dev branch. Even if I have checkbox against "Clean all files in the checkout directory before the build".

My second attempt was to add both of the branches as VCS roots:

VCS Roots

But this caused checkout of both branches into the same directory and whatever was checkout first was overwritten by second branch.

Is there a remedy for our case without creating separate configurations for every branch? (we started from config-per-branch, but that proven to be maintenance heavy for the number of steps we do in build)

1

1 Answers

3
votes

If I understand correctly, you're trying to use a single TeamCity project for both your main and your branch builds. I would not recommend doing that. By re-using the same project for both your main and your branch builds, you will be sharing version numbers between two different beasts. Version 1.1.4 of the build might be a main build while version 1.1.5 might be a branch build.

By looking at the artifacts created by the build, it will also be difficult to identify which source code was the one selected and included into that artifact. Is the executable a main or a branch executable?

The way we solved the main vs branch problem was by creating a "template" project which contains all our build configurations (each one set up as a Build Configuration Template so they can all be changed in a single location) for building our software. Both the main line and the branch projects are created by copying this "template" project and setting the VCS root to the appropriate directory location.

We run five build agents and each build takes a fair amount of time. Having individual projects for each branch allows us to run builds in parallel if the main and any of the branches happen to have been modified at the same time whereas with one single project, the builds would be done serially.

Hope this helps.