0

I have set up 2 environments and protected only one environment.

However pipeline run expect me to approve even before it starts.

I am assuming that Build and DevEnv deployment should happen un attended and should stop for QAEnv alone. Am I missing anything?

enter image description here

enter image description here

enter image description here

forvaidya
  • 3,041
  • 3
  • 26
  • 33

2 Answers2

2

You need to add dependsOn: <environment> to your jobs. As it stands, it's trying to run all of the stages at once.

You also have all of those jobs within a single stage, which looks off to me.

You need to split them into multiple stages:

stages:
- stage: Build
  jobs: ...
- stage: DEV
  jobs: ...
- stage: QA
  jobs: ...
Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
  • It did not work. Gist link of pipeline https://gist.github.com/forvaidya/a1cb133007a7bb87710b266848c0981c – forvaidya Jun 27 '20 at 15:20
  • What does "did not work" mean? Did you get an error? You need to provide detail. – Daniel Mann Jun 27 '20 at 15:23
  • It did wait for approval for all 3 jobs basicBuild, onDevEnv and onQAEnv. I expected that pipeline and onDevEnv will proceed without any intervention. – forvaidya Jun 27 '20 at 15:25
  • @forvaidya That's how you configured your approvals. If an environment has required approvals, it waits for the approval to be given before it proceeds. – Daniel Mann Jun 27 '20 at 15:28
  • Means in the chain of 3 environments (jobs) A->B->C if only C needs approval, whole chain will wait ? just want to make sure. – forvaidya Jun 27 '20 at 15:31
  • 1
    Everything worked. github link for common good. https://github.com/forvaidya/azure-pipelines-env – forvaidya Jun 28 '20 at 08:41
1

Agree with Daniel Mann.

You could split the jobs into two stages (Dev stage and QA stage).

Here is an example:

stages:
- stage: Dev_Stage
  jobs:
  - deployment: DeployWeb
    displayName: deploy Web App
    pool:
      vmImage: 'Ubuntu-latest'
    environment: 'env1'
    strategy:
      runOnce:
        deploy:
          steps:
          - script: echo Hello world

- stage: QA_Stage
  jobs:
  - deployment: DeployWeb
    displayName: deploy Web App
    pool:
      vmImage: 'Ubuntu-latest'
    environment: 'env2'
    strategy:
      runOnce:
        deploy:
          steps:
          - script: echo Hello world

Result:

enter image description here

In this case, the stage1 has no check steps , the stage2 needs to be checked.

If you set the environment for the two stages separately, the two stages are independent of each other, they will not interfere with the other stage.

Hope this helps.

Kevin Lu-MSFT
  • 20,786
  • 3
  • 19
  • 28
  • If there is an existing answer that correctly addresses the question, feel free to edit that question to include any clarifications or additional information that you feel is necessary. There is no need to create a second answer. – Daniel Mann Jun 29 '20 at 13:55