Reputation: 109
I tried to use a variable template containing a variable group in a template with some steps. This is included into a pipeline. Azure tells me that there is "Unexpected value 'variables'" in the template using the variable template.
I tried to make it possible with following code
templates/VariableGroupTemplate.yml:
- variables:
- group: MyVariableGroup
templates/ReferingVariableGroupTemplate.yml:
parameters:
- name: Folder
default: "c:/temp"
variables:
- template: VariableGroupTemplate.yml
steps:
- task: Powershell@2
inputs: Write-Host "Variable from group: $VariableFromGroup -- Folder: ${{ parameters.Folder }}"
The Azure Pipeline tells me that variable in templates/ReferingVariableGroupTemplate.yml does not work.
I used this documentation as a guide: https://learn.microsoft.com/en-us/azure/devops/pipelines/library/variable-groups?view=azure-devops&tabs=yaml
Upvotes: 0
Views: 338
Reputation: 383
The documentation you used tells how to use variable group
If you follow it then it will work.
templates/VariableGroupTemplate.yml:
variables:
- group: MyVariableGroup
templates/ReferingVariableGroupTemplate.yml:
parameters:
- name: Folder
default: "c:/temp"
variables:
- template: VariableGroupTemplate.yml
steps:
- script: echo $(VariableFromGroup)
Upvotes: 1