Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 334
Patty Avatar asked Mar 04 '20 10:03

Patty


People also ask

How is the variables in variable group accessed in Azure DevOps build release definition?

To use a variable group, open your pipeline. Select Variables > Variable groups, and then choose Link variable group. In a build pipeline, you see a list of available groups. In a release pipeline, for example, you also see a drop-down list of stages in the pipeline.

Are release Pipelines deprecated?

Draft releases are deprecated in Azure Pipelines because you can change variables while you're creating the release. Creating a draft release allows you to edit some settings for the release and tasks, depending on your role permissions before you start the deployment.


Video Answer


2 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: 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.

like image 118
Mani Avatar answered Nov 11 '22 16:11

Mani


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.

like image 23
LoLance Avatar answered Nov 11 '22 15:11

LoLance