DevOps Asked by dr.linux on August 22, 2021
I have two separate environments under my repository:
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
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
Answered by qbik on August 22, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP