我有一个包含两个阶段的多阶段YAML管道:1)构建和2)部署。下面提到部署阶段,我想在部署任务之前的那个阶段中添加预部署批准。如何在多阶段YAML管道中添加部署前和部署后批准?
stages:
- stage: 'Build'
# RESTORE
# Some task implementation
# BUILD
# Some task implementation
# PUBLISH
# Some task implementation
# DEPLOY STAGE
- stage: 'Dev'
displayName: 'Deploy to the dev environment'
dependsOn: Build
jobs:
- deployment: Deploy
pool:
vmImage: 'ubuntu-16.04'
environment: dev
variables:
- group: Release
strategy:
# HOW TO ADD PRE DEPLOYMENT AND POST DEPLOYMENT APPROVALS?
runOnce:
deploy:
steps:
- download: current
artifact: drop
- task: AzureWebApp@1
displayName: 'Azure App Service Deploy: website'
inputs:
azureSubscription: 'Resource Manager - Tailspin - Space Game'
appName: '$(WebAppNameDev)'
package: '$(Pipeline.Workspace)/drop/$(buildConfiguration)/*.zip'
答案 0 :(得分:2)
对于此问题,当前只有手动批准和评估工件是可用的检查,并且只能在环境,服务连接和代理池上进行配置。
要定义对环境的批准:
在您的Azure DevOps项目中,转到需要保护的环境。 (了解有关creating an environment的更多信息。)
导航至环境的批准和检查。
选择“创建”,提供批准者和可选消息,然后再次选择“创建”以完成手动批准检查的添加。
然后在yaml文件中使用environment: 'xxx'
参数。例如:
- stage: deploy
jobs:
- deployment: DeployWeb
displayName: deploy Web App
pool:
vmImage: 'Ubuntu-16.04'
# creates an environment if it doesn't exist
environment: 'multiStage'
在这种情况下,GUI和yaml是相互依赖的,不是直接的yaml。
有关详细信息,请参阅此官方document。