Patty
Patty

Reputation: 531

Azure DevOps Release Pipeline - Dropdown list of custom variable

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

Upvotes: 23

Views: 35746

Answers (3)

Eric van Coffee
Eric van Coffee

Reputation: 105

UPDATE: at least 4 values needed

Dropdown appears automatically in Run Pipeline window when you pre-defined at least a certain number of values.

For example, see the following parameter definition with 9 pre-defined values. However, I do not know what the minimum number of values is to display a dropdown.

parameters:
  - name: DATABASE_TIER
    displayName: Tenant Database Tier
    type: string
    default: S0
    values:
      - S0
      - S1
      - S2
      - S3
      - S4
      - S6
      - S7
      - S9
      - S12

enter image description here

Upvotes: 9

Mani
Mani

Reputation: 5648

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.

Upvotes: 29

LoLance
LoLance

Reputation: 28086

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.

Upvotes: 3

Related Questions