Search code examples
azure-devopsazure-pipelinesazure-pipelines-release-pipelineazure-pipelines-yamlazure-yaml-pipelines

How to choose from a selection when running Azure YAML pipeline


When running a YAML pipeline you can select the branch/tag where the YAML is defined. I was wondering if there is a way to have the same thing with an enum type custom variable for your pipeline? For example I want the user to be able to choose which region to deploy to in a release pipeline:

region:

  • amer
  • apac
  • emea

But I don't want to have a plain string variable where the user might enter some bogus region causing issues during pipeline execution.

Is this supported with current Azure YAML pipelines? If not any ideas if there is an existing feature request one can vote for?


Solution

  • It seems that variables is not the right choice here. I should use runtime parameters like so:

    parameters:
    - name: region
      displayName: Deployment Region
      type: string
      default:
      values:
      - AMER
      - APAC
      - EMEA
    

    As Vince pointed out, in order to enforce the user to explicitly choose an option you can leave the default blank.