Azure-devops-docs: Clarify use of stageList parameter data usage (supply example)

Created on 26 Feb 2020  Â·  2Comments  Â·  Source: MicrosoftDocs/azure-devops-docs

There is no example given on how to use stageList, and I am unable to determine how to do this (even by looking at stepList)

Please give a detailed instruction on how to use this, as my example below reports back an error:

Pipeline parameters not enabled

name: ProvisionSP

pr: none
trigger: none
variables:
  terraformVersion: 0.12.20

parameters:
- name: buildStage
  type: stage
  default: [
    164e47ad8642
    209ab84d2588
    ba3902bed814
  ]

stages:
- ${{ each stage in parameters.buildStage }}:
  - template: /.pipelines/01_stage/sp_deploy.yml
    parameters:
      subscription_id: ${{ buildStage.stage }}
      terraformVersion: ${{ variables['terraformVersion'] }}

Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri1 devops-cicd-procestech devopprod doc-enhancement

All 2 comments

I don't understand what you're trying to do. What's with the default value?

stageList allows you to enforce that the parameter is a sequence of stages:
```yaml
name: ProvisionSP

pr: none
trigger: none
variables:
terraformVersion: 0.12.20

parameters:

  • name: buildStage
    type: stageList
    default:

    • stage:

      jobs:



      • job:


        steps:





        • script: echo "hello"






stages:

  • ${{ each stage in parameters.buildStage }}:

    • ${{ stage }}

I've figured it out

YAML file which gets executed in Az DevOps:

name: ProvisionSP

pr: none
trigger: none
variables:
  terraformVersion: 0.12.20

stages:
- template: /.pipelines/01_stage/sp_deploy_each.yml
  parameters:
    pool:
      # vmImage: Ubuntu 18.04
      name: backupAgents
    subs:
    - 164e47ad8642
    - 209ab84d2588
    - ba3902bed814
    - f5e7fb2e0c7b
    terraformVersion: ${{ variables['terraformVersion'] }}

...and the file that it calls; sp_deploy_each.yml;

parameters:
  pool: {}
  subs: []

stages:
- ${{ each job in parameters.subs }}:
  - stage: Deploy_${{ job }}
    displayName: "${{ job }} Deploy"
    condition: |
      and
      (
        ne(canceled(), true),
        ne(failed(), true),
        ne(variables['terraformDestroy'], 'yes')
      )
    variables:
    - template: /.pipelines/config/sub-${{ job }}.config.yml
    jobs:
    - template: /.pipelines/02_jobs/sp_01_scaffolding.yml
      parameters:
        pool: ${{ parameters['pool'] }}
        terraformBackendContainerName: ${{ variables['TERRAFORM_BACKEND_CONTAINER_NAME'] }}
        terraformBackendKeyName: ${{ variables['ENVIRONMENT_NAME'] }}
        terraformBackendStorageName: ${{ variables['TERRAFORM_BACKEND_STORAGE_NAME'] }}
        terraformVersion: ${{ parameters['terraformVersion'] }}
        vaultName: ${{ variables['VAULT_NAME'] }}
        vaultSvcConnection: ${{ variables['VAULT_SVC_CONNECTION'] }}

- ${{ each job in parameters.subs }}:
  - stage: Destroy_${{ job }}
    displayName: "${{ job }} Destroy"
    condition: |
      and
      (
        ne(canceled(), true),
        ne(failed(), true),
        eq(variables['terraformDestroy'], 'yes')
      )
    variables:
    - template: /.pipelines/config/sub-${{ job }}.config.yml
    jobs:
    - template: /.pipelines/02_jobs/sp_01_scaffolding_destroy.yml
      parameters:
        pool: ${{ parameters['pool'] }}
        terraformBackendContainerName: ${{ variables['TERRAFORM_BACKEND_CONTAINER_NAME'] }}
        terraformBackendKeyName: ${{ variables['ENVIRONMENT_NAME'] }}
        terraformBackendStorageName: ${{ variables['TERRAFORM_BACKEND_STORAGE_NAME'] }}
        terraformVersion: ${{ parameters['terraformVersion'] }}
        vaultName: ${{ variables['VAULT_NAME'] }}
        vaultSvcConnection: ${{ variables['VAULT_SVC_CONNECTION'] }}

Hopefully I've saved some headaches for people by posting this.

Was this page helpful?
0 / 5 - 0 ratings