forvaidya
forvaidya

Reputation: 3315

Azure Pipelines environments approvals

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

Upvotes: 1

Views: 961

Answers (2)

Kevin Lu-MSFT
Kevin Lu-MSFT

Reputation: 35634

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.

Upvotes: 2

Daniel Mann
Daniel Mann

Reputation: 59074

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: ...

Upvotes: 2

Related Questions