I have the following setup, a template file, and a pipeline that extends the template. I am wondering is it possible to dynamically add all parameters to extends' parameter?
Template.yml
parameters:
- name: Location
type: string
default: 'eastus'
Washington.yml
parameters:
- name: Location
type: string
default: 'westus'
extends:
template: Template.yml
parameters:
Location: ${{ parameters.Location }}
I can do something like this but I think it doesn't work because the shadowed parameters
variable will be used instead of root level parameters
.
parameters:
- name: Location
type: string
default: 'westus'
extends:
template: Template.yml
parameters:
- ${{ each param in parameters }}
${{ param.Name }}: ${{ param.Value }}
CodePudding user response:
This works for me:
parameters:
- name: Location
type: string
default: 'westus'
extends:
template: Template.yml
parameters:
${{ each param in parameters }}:
${{ param.Key }}: ${{ param.Value }}
So you had small syntax issues.
It printed:
Assuming that template is:
parameters:
- name: Location
type: string
default: 'eastus'
steps:
- script: echo ${{ parameters.Location }}