8

We use TFS source control and have two build controllers (one VS2010 the other VS2012). We use the default build workflow template bar a few custom changes.

As we have many branches, how would we go about changing the workspace based on the desired branch?

I was thinking of adding a parameter for the branch ($\oursourcecontrol\branches\main) and then just passing it as a variable in to the get workspace part of the workflow.

Or is there a better way of doing it?

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
MrBeanzy
  • 2,286
  • 3
  • 28
  • 38

2 Answers2

9

You currently can't and it is really a shame. It would completely break the Trigger support for CI and Gates checkins. You can use the TFS Community Build Manager to quickly clone and adjust build definitions to support multiple branches though.

What you could do, is to fetch more than you need (say $/Sourcecontrol/Branches/*) and then use a string-replace on any path parameter (like solutions to build, test settings file etc) to point them all to the correct solution. You'll probably need to do some templating like {BRANCH} so that you can easily replace these tokens.

The Git build template does support this on a Git repository, but you'd need TFS 2013 to make use of server side Git support.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • Thanks Jesse, I did think about getting all our branches but it would be some 300GB so might take a while. Even after I exclude the stuff we dont need. Ill check out the TFS Community Build Manager – MrBeanzy May 29 '14 at 12:13
  • 1
    I want to add that many teams standardize on a structure for their version control branches (i.e. hey can always be found in the same VC folder) and customize the Build Workflow so that the branch name is given as Build Argument and replaced within the Build Template. – Giulio Vian Jan 27 '15 at 08:20
-1

I mapped the server path in the Repository tab at higher level that TFS branches are contained. Cloak rest of the branches not required for Get sources step except the branch to be built. And create variable to pass the branch name, check allow at queue time. Use this branch variable in build steps to make the build definition work for all the branches. You may need more than one variable based on your branches structure in TFS.

Sri
  • 1