首页 > 解决方案 > 在 Azure YAML 管道中实现 Gates

问题描述

我已经看到并使用过 Azure 发布管道。

我们希望使用基于 YAML 的管道,因为它很容易在 Git 中进行版本控制。有没有办法在 Stages 中拆分管道,每个阶段都有后续阶段的批准者和手动触发器。

标签: azureazure-devopsazure-pipelines

解决方案


在 YAML 中,它以不同的方式工作。要使用批准和检查,您需要先定义环境。一旦你有了一个环境,你就可以定义approvals and checks.

在此处输入图像描述

重要的是

yaml 文件中未定义批准和其他检查。修改管道 yaml 文件的用户无法修改阶段开始之前执行的检查。资源管理员使用 Azure Pipelines 的 Web 界面管理检查。

然后在部署作业中,您可以选择环境:

jobs:
- deployment: string   # name of the deployment job, A-Z, a-z, 0-9, and underscore
  displayName: string  # friendly name to display in the UI
  pool:                # see pool schema
    name: string
    demands: string | [ string ]
  dependsOn: string 
  condition: string 
  continueOnError: boolean                # 'true' if future jobs should run even if this job fails; defaults to 'false'
  container: containerReference # container to run this job inside
  services: { string: string | container } # container resources to run as a service container
  timeoutInMinutes: nonEmptyString        # how long to run the job before automatically cancelling
  cancelTimeoutInMinutes: nonEmptyString  # how much time to give 'run always even if cancelled tasks' before killing them
  variables: { string: string } | [ variable | variableReference ]  
  environment: string  # target environment name and optionally a resource-name to record the deployment history; format: <environment-name>.<resource-name>
  strategy: [ deployment strategy ] # see deployment strategy schema

您也可以在 github 上查看此主题

没有计划在 YAML 中添加批准。但是,我们确实计划支持对各种资源(例如服务连接、变量组、代理池等)配置审批。

而且没有大门(至少现在)。因此,您无法通过批准特定阶段来保护,但您可以保护作业中使用的一些资源(如环境)。


推荐阅读