In our TFS2018 website I have made build definitions for our development branch and our release branch. The release branches have the following naming convention: Release_yyyy_mm_dd.
DEV Branch
|
-- Release Folder
| |
| -- Release_2018_01_01 Branch
| -- Release_2018_01_15 Branch
| -- Release_2018_01_29 Branch *current*
We have lots of code that needs to be build (MAP the folder) and lots of code that doesn't (CLOAK the folder).
E.g.:
MAP Release_2018_02_22\ServiceA
MAP Release_2018_02_22\ServiceB
CLOAK Release_2018_02_22\ServiceC
CLOAK Release_2018_02_22\GigsOfDataThatDoesntNeedGetting
*repeat this for 50 folders*
We release every sprint, so I have to adapt the release branch folder every time. That's why I introduced a build variable $(CurrentReleaseBranch).
E.g:
$(CurrentReleaseBranch) on the variables TAB set to "Release_2018_02_22".
MAP $(CurrentReleaseBranch)\ServiceA
MAP $(CurrentReleaseBranch)\ServiceB
CLOAK $(CurrentReleaseBranch)\ServiceC
CLOAK $(CurrentReleaseBranch)\GigsOfDataThatDoesntNeedGetting
*repeat this for 50 folders*
I have a gated check in trigger on this build definition, with the option Use workspace mappings for filter checked.
When checking in code on this branch, a gated check in will not be shown.
When I use hardcoded paths in the mappings, the gated check in dialog does appear in Visual Studio.
How can I use variables and still have a gated check in?
You can't. Variables in path mappings are not supported. If you need to support many different branches in this fashion, the easiest option is going to be automating what you want to do with a combination of a scripting language such as PowerShell and the REST API to clone/update the build definition JSON.