8
votes

For Azure DevOps Release pipeline, is it possible to create Dropdown list for custom variables?

So for below, if I wish to have dropdown values instead of single text value enter image description here

2

2 Answers

11
votes

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: image
  displayName: Pool Image
  type: string
  default: ubuntu-latest
  values:
  - windows-latest
  - vs2017-win2016
  - ubuntu-latest
  - ubuntu-16.04
  - macOS-latest
  - macOS-10.14

trigger: none # trigger is explicitly set to none

jobs:
- job: build
  displayName: build
  pool: 
    vmImage: ${{ parameters.image }}
  steps:
  - script: echo building $(Build.BuildNumber) with ${{ parameters.image }}

This results in the following.

result

More info on Runtime parameters can be found here. Hope this helps.

The only downside with this is that since we are specifying trigger as none we may not be able to integrate into an automatic pipeline. I've not yet tried it. Let me know if it works in an auto pipeline.

Note: The example and image shown here is fetched from azure DevOps documentation.

3
votes

As I know the dropdown value is not supported yet.

The custom variable in release pipeline is a key-value pair, the value should be one specific value instead of a dropdown list. The value could be single text value, could be true/false or other variable using format $(VarName) from variable group. But we can't pass a dropdown list as value to the variable.