3

Is it possible in azure-pipelines.yml to define multi-value at runtime parameters so when you run the build you have to input so values

parameters:
  - name: image
    displayName: Pool Image
    type: string
    default: ubuntu-latest
    values:
    - windows-latest
    - vs2017-win2016
    - ubuntu-latest

Upon clicking Run in Azure DevOps you are presented with a dropdown and you select which option you require ???

Upon your selection, the build will only run certain steps or tasks based on your selection

1
  • Hi Dropdown parameters is not yet supported in azure devops pipeline. Did you try out below workaround? Commented Mar 11, 2020 at 9:27

2 Answers 2

7

I am not sure when it was added, but drop down parameters are now available:

parameters:
  - name: env
    displayName: Environment
    type: string
    values:
      - dev
      - prod
      - test
      - train
    default: train

will provide me with a drop down of dev, prod, etc., prepopulated with the value train.

Moreover, it will be a drop down if 4 values or more, and a radio dial with 3 or less. For instance,

  - name: department
    displayName: Business Department
    type: string
    values:
      - AI
      - BI
      - Marketing
    default: AI

will create a radio dial with AI selected by default. Note that the YAML is identical between the two, with the exception of 4 values in the first and 3 in the second.

Sign up to request clarification or add additional context in comments.

Comments

2

Dropdown parameters is not yet supported on azure devops pipeline.

There is a workaround that you can create a variable with all the possible values, and enable Settable at queue time. The detailed steps are in below:

Edit your yaml pipeline, Click the 3dots on the top right corer and choose Triggers

enter image description here

Go to Variables tab, create a variable and check Settable at queue time

enter image description here

Then when you queue your pipeline, you will be allowed to set the value for this variable.

enter image description here

After you setup above steps. You also need to add condtions for your tasks.

For below example the script task can only run when the Environment variable is equal to prod and previous steps are all succeeded.

steps:
  - script: echo "run this step when Environment is prod"
    condition: and(succeeded(), eq(variables['Environment'], 'prod'))

Please check here for more information about Conditions and Expressions

You can also submit a feature request (Click suggest a feature and choose Azure devops)to Microsoft Develop, hope they will consider implementing this feature in the future.

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.