Search code examples
azureazure-devopsazure-pipelinesmultistage-pipeline

Azure devops multi-stage YAML combined with manual interaction


I'm just reading about the multi-stage pipelines which sound awesome.

As far I understand, the stages run after each other, now suppose I have the following stages

stages:
   stage: Deploy to acc
      ...
   stage: Deploy to prd

I don't want to run the production deployment right after the deployment to acc. First I want to look at acc and when I approve it should deploy to prd. Is there a way in the multi-stage pipeline to tell not to automatically run a stage? And run a stage manually for example? Or should I create a new pipeline just for production?


Solution

  • To prevent stage from automatically run, you can add conditions to each stage. Check here for more information

    stages:
    - stage: A
      #stage B runs if A fails
    - stage: B
      condition: failed()
     #stage C runs if B succeeds
    - stage: C
      dependsOn:
      - A
      - B
      condition: succeeded('B')
    

    If you want to run a stage mannually. You can create checks for your environments. Follow below steps to create environments where your stage targets on.

    Navigate to the Pipelines page. Then choose Environments and click on Create Environment. For more information check here

    And Then follow the instruction here to create checks for each environment. In this way, before your pipeline stage starts to deploy to an environment with the checks defined. It will wait for the approval.

    It is suggested to deploy your app with release pipeline. You can create Release pipeline in Releases Page in your project. Create approvals and gates to manually intervene your deployment task is quite straightforward in release pipeline. Check here for detailed steps