Chris
Chris

Reputation: 27384

Using one build task to build any branch checked in within Source Folder

I currently have two build scripts setup for my development branches for my project, Main and Dev. Releases are done from Main and all development work is checked into Dev.

Ideally I'd like Dev to be a folder with any number of branches beneath it. Because branches could be created and deleted at will I want to modify my existing build script to look for any branch change and build that but I'm not sure how.

Triggers

Current my trigger is set to Include: $/MyCompany/Dev. If I altered Dev to be a folder and had branches within it it should trigger for every branch checking below that folder, great... But... How do I modify my build task to only build the branch that was changed? Also will it pull down every branch under that folder? That would slow down the build tremendously.

Build Task

Solution: **\*.sln

What should I change this to, so that it only builds the branch that changed?

Note I intend to have 3 build configurations. One for Release [from Main], one for Beta [from Dev] and an Alpha release from feature branches.

Edit

I found you can use $(Build.SourceBranch) which looks useful when building but it doesnt seem to work when getting sources?

Upvotes: 0

Views: 829

Answers (2)

starian chen-MSFT
starian chen-MSFT

Reputation: 33698

As Daniel said that you can’t do what you’re trying to do with TFVC, git is the better way.

On the other hand, if you trigger build manually, you can refer to these steps to build with specific branch.

  1. Edit your build definition
  2. Add variable (e.g. BranchToBuild) and check Allow at Queue Time
  3. Change repository mapping like $/MyCompany/$(BranchToBuild)
  4. Queue build and specify BranchToBuild variable's value.

Regarding your scenario (CI build), you can group steps/tasks, then create multiple build definitions with that task group for each branch.

More information of Task Group, you can refer to Task Groups

Upvotes: 2

Daniel Mann
Daniel Mann

Reputation: 59020

You can't do what you're trying to do with TFVC. Git supports the scenario you'd like to implement.

Upvotes: 1

Related Questions