Search code examples
azure-devopsmultistage-pipeline

How to ask for change request id for a specific Azure DevOps stage


I am trying to build a multi-stage pipeline to deploy an application to Dev -> QA -> Production and I am able to do all of that using Azure DevOps YAML pipeline. Furthermore I want any deployments to Production environment to require a change request id, basically a text string, from the person approving the deployment to production. It does not require any validation of the value of the text string, other than it must not be empty, i.e. a required field.

I do not want any deployment to neither Dev or QA to require that change request id, only when a deployment is promoted to Production environment is a change request id required.

How to do this with Azure DevOps YAML pipelines?


Solution

  • I do not want any deployment to neither Dev or QA to require that change request id, only when a deployment is promoted to Production environment is a change request id required.

    You could add the condition for the stage with '' to indicate non-existence or no value:

    stages:
    - stage: Production 
      condition: ne(variables['changeRequestId'], '')
      jobs:
      - job: Production 
        displayName: Production 
        pool:
          vmImage: 'windows-latest'
        steps:
            - script: |
               echo $(changeRequestId)