Passing steps as parameters
08:23 07 Nov 2024

My pipleine.yaml extends another template.yaml. There is a parameter prePlanSteps available in the template to allow me to add steps to the master.

My test script is simply:

echo region = ${{ env.region }}

This works if I put it directly as an inline step. However it fails if I try to pass the same code to the prePlanSteps parameter:

Unrecognized value: 'env'.

I've obviously got to pass this in a particular format/syntax to get it to resolve at the right time/place, but I can't work out how.

template.yaml:

parameters:
- name: envList
  type: object
- name: prePlanSteps
  type: stepList
  default: []

  - ${{ each env in parameters.envList }}:
    - stage: "${{ env.name }}Build"
      variables:
      jobs:
      - job: 'Plan'
        steps:
          - bash: |
              echo region = ${{ env.region }}

          - ${{ parameters.prePlanSteps }}

pipeline.yaml:

 extends:
  template: template.yml
  parameters:
    envList:
      - name: dev
        region: myRegion
    prePlanSteps:
      - bash: |
          echo region = ${{ env.region }}
        displayName: preplansteps_test
        name: preplansteps_test
azure-devops azure-pipelines-yaml