I am very new to Azure pipeline and I am stuck in an issue from pas one week. I have a Selenium c# test case which I have to execute on pipeline. I must use the Variable groups as the input parameters for my test cases. So, I have created appsettings.json file appsettings.json
In my YAML code, I am able to read the variable groups, but I am not able to use it's values in the pipeline.How to do it?
To use a variable from a variable group, you need to add a reference to the group in your YAML file:
variables:
- group: my-variable-group
Thereafter variables from the variable group can be used in your YAML file.
If you use both variables and variable groups, you'll have to use name/value
syntax for the individual (non-grouped) variables:
variables:
- group: my-variable-group
- name: my-bare-variable
value: 'value of my-bare-variable'
To reference a variable group, you can use macro syntax or a runtime expression. In this example, the group my-variable-group
has a variable named myhello
.
variables:
- group: my-variable-group
- name: my-passed-variable
value: $[variables.myhello] # uses runtime expression
steps:
- script: echo $(myhello) # uses macro syntax
- script: echo $(my-passed-variable)
You can also reference multiple variable groups in the same pipeline, and link an existing Azure key vault to a variable group and map selective vault secrets to the variable group.
Check Add & use variable groups for more information and examples. Refer to this blog post for a detailed walkthrough.