Dynamic branch in TFS2015 build

Question!

Is there a way to dynamically specify the branch name in a step with the build definition in TFS2015 (not old XAMLs)? For example I would like to specify a parameter to an MSBuild step using a variable containing the branch name: http://i.stack.imgur.com/P8Nis.png

The project to build here should be something like: $Datawarehouse\$(BranchParameter)\Project\Project.sln

and I want to specify the parameter $(BranchParameter) at running time.



Answers
No such option to specify the parameter $(BranchParameter) at running time by default. TFS get the repository which is specified in mappings on the Repository tab. enter image description here

However, you can write your own script and add a PowerShell task to get sources that you want.



we can have branch name as a parameter and pass the branch name while triggering a build in VS. 1. Create an Argument "Branch Name" , Add in metadata and make it "Always Show the parameter" 2. Modify the "Pull sources from Git repo" activity with branch name parameter 3. Save the template and commit the changes 4. Edit build definition and select the modified template.

While queue a build you can find the BranchName parameter and pass the branch name and trigger a build.

Instead of having different build definition for each branch. you can have one build definition and pass branch name every time you trigger a build.

Hope this helps.

Thanks,

$hree



This video can help you solving your question :)
By: admin