I have a below variables.yml file
variables:
vmImage: ubuntu
poolName: 'cloud'
env: Dev
module: $(moduleName)
sc: abc-dev
rg: abc-dev-rg
location: eus2
I would like to toggle the value of sc,rg and location based on the value of $(moduleName). Is this possible to achieve.
something like this
- ${if eq($(modulename), 'abc') }:
sc: abc-dev
rg: abc-dev-rg
location: eus2
- ${if eq($(modulename), 'xyz') }:
sc: xyz-dev
rg: xyz-dev-rg
location: scus
I tried using multiple if conditions but looks like this cannot be done is variables.yml file. So I was looking for any alternative options.
2
Answers
variables.yml
main.yml
change the module value in variables, you should get the corresponding result. hope this can help you.
Based on my test, we cannot use condition to assign values to variables in variable template.
As a workaround, you can create a variable template for each moduleName and then select the corresponding template based on the value of moduleName. For example, create variable templates "abc-var.yml" and "xyz-var.yml".
xyz-var.yml:
In the main yaml, define
modulename
as parameter and select template based on the value ofmodulename
.When you run the pipeline, you can select the value of
modulename
from UI.