nopassport1
nopassport1

Reputation: 1944

Force a user to enter a variable in the UI before running a pipeline in Azure Dev Ops

I have an existing YAML Azure Dev Ops Pipeline.

In order to build/ deploy a new release, users have to press the Run Pipeline button in Azure Dev Ops.

enter image description here

Which brings up the following menu:

enter image description here

I would, at this point, like to ask the user to set the value of a variable. enter image description here

Something to prompt them & prevent them from proceeding. Is that possible to do via a YAML pipeline? If so, how can I achieve this?

The idea is for me to ask the user for an input before allowing them to proceed & create a new build etc. as there is a build step which relies on said variable to be set prior to build.

Upvotes: 3

Views: 2999

Answers (2)

Udith Indrakantha
Udith Indrakantha

Reputation: 980

With the following YAML code, yu can achieve something like below.

parameters:
  - name: Mode
    displayName: Specify the mode
    default: DEV
    type: string

enter image description here

The parameter must be referenced in the template using ${{ parameters.Mode}} , the other variable syntaxes don't work.

Upvotes: 3

Shayki Abramczyk
Shayki Abramczyk

Reputation: 41755

I don't think you can make a variable as mandatory, but as you said, you can add a simple step to check if the user is put some value:

- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
      if($env:testVariable -eq "")
      {
          Write-Error "testVariable variable is empty!"
      }

Upvotes: 2

Related Questions