azure-devopsparametersado

Dynamically Set the Allowed Values of a Parameter in Azure DevOps?


Is there a way to set the allowed values of a parameter in Azure DevOps using some kind of a variable? For example, let's say we have this parameter in 100 different pipelines:

parameters:   
 - name: value   
    type: string  
    values: [value1, value2, value3, value4, value5, value6, value7]

I want to be able store the values array below somewhere global.

The only way that have worked so far is a script that over-writes all the parameters with a specific name. For example:

  1. Scan all files for parameter with name "value"
  2. If found, over-write it with the updated values array. However, this is far from ideal.

Here is what hasn't worked:

Using Global Variables

variables:
  - group: variable-group

parameters:
  - name: value
    type: string
    values: [${{ variables.valueList }}]

Using Template

parameters:
    template: values.yml 

OR: 

extend: values.yml 

With values.yml:

parameters:   
 - name: value   
    type: string  
    values: [value1, value2, value3, value4, value5, value6, value7]

It's also important that those values are visible when triggering the pipeline manually.

Anchors aren't supported by ADO. Any other ideas?


Solution

  • Is there a way to set the allowed values of a parameter in Azure DevOps using some kind of a variable?

    I am afraid that Azure DevOps doesn't support using variable value in the value of the parameters.

    Currently, only hard-coded Parameter values ​​are supported in Azure Pipeline.

    On the other hand, the parameters field in the main yaml cannot use template. And if you define the parameters in template, it can not be seen when manually running the Pipeline.

    In all, your requirement cannot be met for the time being.

    I can fully understand your requirement. You can submit a suggest ticket in the site: Developer Community to report this feature.