The following azure pipeline code gives error
'A template expression is not allowed in this context'
variables:
major: 2020
minor: 3
patch: 1
major_minor_patch: $(major).$(minor).$(patch)
trigger:
- master
- Dev
- release/R${{variables.major_minor_patch}}
- release/${{variables.major_minor_patch}}/*
My intention is to use the major, minor and patch variables to specify the branches that would form the CI trigger, instead of hard coding it in the pipeline YAML.
- What am I missing because I can't find documentation which addresses my scenario?
- If what ever I am trying to do is unsupported, are there suggested ways of achieving the same?
Thanks
Variables in trigger block is not supported. See document here for more information.
If you do not want the pipeline be triggered by other branches, you can try below workaround.
Create an additional pipeline to check if the source branch match release/major_minor_patch. And trigger the main pipeline in this additional pipeline.
In above pipeline. It will be triggered first to check if the source branch match the farmat. And if it matches, then task TriggerBuild will be executed to trigger the main pipeline.