With yaml pipelines, is there a way to select an environment parameter from a dynamic list of all environments?

Viewed 324

We've been migrating some of our manual deployment processes from Octopus to Azure DevOps Yaml pipelines. One of the QoL changes we're sorely missing is to be able to select the environment from a drop-down list/ auto-complete field as we could in Octopus.

Is there a way to achieve this? Currently, the only way I can think of doing it is to have a repo with a .yaml template file updated with a list of new environments as part of our provisioning process... Which seems less than ideal.

1 Answers

If you are going to trigger the pipeline manually then you can make use of Runtime parameters in the Azure DevOps pipeline.

For Example: In order to make OS image name selectable from a list of choices, you can use the following snippet.

parameters:
- name: EnvName
  displayName: EnvName
  type: string
  default: A
  values:
  - A
  - B
  - C
  - D
  - E
  - F

trigger: none # trigger is explicitly set to none

jobs:
- job: build
  displayName: build

  steps:
  - script: echo building $(Build.BuildNumber) with ${{ parameters.EnvName }}

enter image description here

Documentation about runtime parameters are here.

The downside to this is that the trigger: None limits you that the pipeline can only be manually triggered. Not sure how this works with other trigger options.

Related