I have a variable group that I want to be run an expression in. That is I want to have the variable group's variable contents be computed at runtime.
Variables_General has a variable called isMain with the content $[contains(variables['Build.SourceBranch'], 'refs/heads/develop')]
variables:
- group: Variables_General
...
condition: variables.isMain
But this isn't working as desired. I've tried various combinations of double quoting, using $[],and $(). I've tried this in both the variable value and how the variable is referenced. It does one of two things, Says it wasn't expecting "$" or simply detects that the variable has content and therefore is "true"
What is the correct way to have code in a variable group's variable's value that gets evaluated at runtime?
Yaml reference the variable group, but can not parse the expression. Yaml treats the $[contains(variables['Build.SourceBranch'], 'refs/heads/develop')] in variable group as characters.
You may submit a suggestion on the website below:
https://developercommunity.visualstudio.com/content/idea/post.html?space=21
Currently, you may define the isMain variable separately in the variables:
variables:
- group: Variables_General
- name: isMain
value: $[contains(variables['Build.SourceBranch'], 'refs/heads/master')]
steps:
- script: echo Hello!
condition: eq(variables.isMain, true)