<p>Environment approvals work per-stage. Split your jobs into separate stages:</p>
<pre class="lang-yaml prettyprint-override"><code>stages:
  - stage: development
    condition: contains(variables['Build.SourceBranch'], 'refs/heads/develop')
    jobs:
    - deployment: Deploy_Dev
      displayName: 'Deploy Develop to Dev Machine'
      pool:
        name: Development
      environment: 'development'
      strategy:
        runOnce:
          deploy:
            steps:
              - checkout: none
              - task: Bash@3
                inputs:
                  targetType: 'inline'
                  script: |
                    echo $(hostname)
                  workingDirectory: '/var/www'
                  noProfile: false
                  noRc: false

  - stage: production
    condition: contains(variables['Build.SourceBranch'], 'refs/heads/master')
    jobs:
    - deployment: Deploy_Master_to_Hotfix
      displayName: 'Deploy Master to Hotfix Machine'
      pool:
        name: Hotfix
      environment: 'production'
      strategy:
        runOnce:
          deploy:
            steps:
              - checkout: none
              - task: Bash@3
                inputs:
                  targetType: 'inline'
                  script: |
                      echo $(hostname)         
                  workingDirectory: '/var/www'
                  noProfile: false
                  noRc: false
</code></pre>

CC BY-SA 4.0
2021-04-14T04:05:09.523Z
2021-04-14T04:05:09.523Z
qbik
<p>I have two separate environments under my repository:</p>
<ul>
<li>development (Approvals are not configured but the environment exists)</li>
<li>production (Approvals rules are configured via dev.azure.com UI)</li>
</ul>
<p>The problem is, even we try to deploy to the development environment, the pipeline asking for approval. How we can fix the issue? Below, you can see simple two deploy jobs from YAML:</p>
<pre><code>jobs:
    - deployment: Deploy_Dev
      displayName: 'Deploy Develop to Dev Machine'
      pool:
        name: Development
      condition: contains(variables['Build.SourceBranch'], 'refs/heads/develop')
      environment: 'development'
      strategy:
        runOnce:
          deploy:
            steps:
              - checkout: none
              - task: Bash@3
                inputs:
                  targetType: 'inline'
                  script: |
                    echo $(hostname)
                  workingDirectory: '/var/www'
                  noProfile: false
                  noRc: false

    - deployment: Deploy_Master_to_Hotfix
      displayName: 'Deploy Master to Hotfix Machine'
      pool:
        name: Hotfix
      condition: contains(variables['Build.SourceBranch'], 'refs/heads/master')
      environment: 'production'
      strategy:
        runOnce:
          deploy:
            steps:
              - checkout: none
              - task: Bash@3
                inputs:
                  targetType: 'inline'
                  script: |
                      echo $(hostname)         
                  workingDirectory: '/var/www'
                  noProfile: false
                  noRc: false
</code></pre>

<git><azure-devops><deployment><azure><azure-pipelines>
Azure deploy pipeline with/without approval on separated enviroments
dr.linux
# Azure deploy pipeline with/without approval on separated enviroments

(Asked by: username_0 on 2020-07-08)

I have two separate environments under my repository:

development (Approvals are not configured but the environment exists)
production (Approvals rules are configured via dev.azure.com UI)

The problem is, even we try to deploy to the development environment, the pipeline asking for approval. How we can fix the issue? Below, you can see simple two deploy jobs from YAML:
jobs:
    - deployment: Deploy_Dev
      displayName: 'Deploy Develop to Dev Machine'
      pool:
        name: Development
      condition: contains(variables['Build.SourceBranch'], 'refs/heads/develop')
      environment: 'development'
      strategy:
        runOnce:
          deploy:
            steps:
              - checkout: none
              - task: Bash@3
                inputs:
                  targetType: 'inline'
                  script: |
                    echo $(hostname)
                  workingDirectory: '/var/www'
                  noProfile: false
                  noRc: false

    - deployment: Deploy_Master_to_Hotfix
      displayName: 'Deploy Master to Hotfix Machine'
      pool:
        name: Hotfix
      condition: contains(variables['Build.SourceBranch'], 'refs/heads/master')
      environment: 'production'
      strategy:
        runOnce:
          deploy:
            steps:
              - checkout: none
              - task: Bash@3
                inputs:
                  targetType: 'inline'
                  script: |
                      echo $(hostname)         
                  workingDirectory: '/var/www'
                  noProfile: false
                  noRc: false

**Tags:** git, azure-devops, deployment, azure, azure-pipelines


---

## 1 answers

### Answer by username_1 on 2021-04-14. Score: 1

Environment approvals work per-stage. Split your jobs into separate stages:
stages:
  - stage: development
    condition: contains(variables['Build.SourceBranch'], 'refs/heads/develop')
    jobs:
    - deployment: Deploy_Dev
      displayName: 'Deploy Develop to Dev Machine'
      pool:
        name: Development
      environment: 'development'
      strategy:
        runOnce:
          deploy:
            steps:
              - checkout: none
              - task: Bash@3
                inputs:
                  targetType: 'inline'
                  script: |
                    echo $(hostname)
                  workingDirectory: '/var/www'
                  noProfile: false
                  noRc: false

  - stage: production
    condition: contains(variables['Build.SourceBranch'], 'refs/heads/master')
    jobs:
    - deployment: Deploy_Master_to_Hotfix
      displayName: 'Deploy Master to Hotfix Machine'
      pool:
        name: Hotfix
      environment: 'production'
      strategy:
        runOnce:
          deploy:
            steps:
              - checkout: none
              - task: Bash@3
                inputs:
                  targetType: 'inline'
                  script: |
                      echo $(hostname)         
                  workingDirectory: '/var/www'
                  noProfile: false
                  noRc: false


---

