Re1ter
Re1ter

Reputation: 399

How to create a toggle on yaml in the starting variables of the azur devops pipeline?

I have a pipeline that uses a variable that can take multiple hardcoded values. This variable is available on the pipeline launch screen, and the user must fill it in. As a result, typos happen and the pipeline doesn't work. Can I make this variable a toggle so that the user, instead of entering a value, selects it from the list of available ones?

How it looks now

Upvotes: 1

Views: 769

Answers (1)

Krzysztof Madej
Krzysztof Madej

Reputation: 40779

You can't do this for variable but you can use ofr that purpose runtime parameters.

For instance:

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

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

produces:

enter image description here

Upvotes: 3

Related Questions