在 Azure Pipelines 中,当托管在 Azure Repos 中时,是否有办法在具有开放 PR 的分支上禁用 CI?

Ian*_*ett 2 git azure-devops azure-pipelines azure-repos

我们有一个用例,我们的代码完全托管在 Azure DevOps 中(管道、存储库等)。我们需要构建和部署“完整”构建/部署流程来部署无服务器功能。我们理想的情况是在 PR 打开和更新时有一个单一的构建/部署过程。Individual CI我们有一个构建验证策略,当 PR 接受另一个策略时,我们希望忽略该构建push,因为Build Validation策略应该取代该trigger块。

pr由于Azure Repos 无法使用触发器,有没有办法实现此目的?

存储库类型:Azure 存储库 Git

# The pipeline will fail if a branch is not either 'main' or 'something/12345-something'
trigger:
  paths:
    exclude:
      - azure-pipelines-cleanup.yaml
      - docs
      - README.md

name: $(SourceBranchName).$(Rev:r)_$(Build.RequestedFor)

resources:
  repositories:
    - repository: pipeline
      type: git
      name: <Org Obscured>/infra-pipeline
      ref: feature/212242-pipeline-housecleaning # this is pipeline branch ref, should be main unless testing pipeline changes

# This extends a template from the central pipeline repo
extends:
  template: service-pipeline-template.yaml@pipeline
  parameters:
    appName: starter
    publishSdk: true
Run Code Online (Sandbox Code Playgroud)

构建验证设置

结果:两个构建,一个Invididual CI,一个PR automated同时触发 双重触发构建 - 单独的 CI 和 PR 自动化

期望:仅PR automated构建。

这不是条件表达式本身的问题,除非有一种方法可以在 PR 中运行完整管道的同时完全禁用触发器块。我不认为有办法在 ADO 中运行服务器端 git hooks。

Kev*_*SFT 5

恐怕没有这样的方法可以仅在 PR 触发器存在时禁用 CI 触发器。

\n

在Azure Devops中,CI触发器和PR触发器是两个独立的触发器。如果同时满足触发条件,则管道会被触发两次。

\n

以下是CI触发PR触发的触发条件。

\n

但是,有一种解决方法可以实现您想要的状态。

\n

您可以[skip ci]在推送更改时添加提交消息。

\n

在此输入图像描述

\n

然后 CI 触发将被跳过。并且这个commit只会触发PR触发Build。

\n

以下是等效的提交消息\xef\xbc\x9a

\n
\n

[跳过 ci] 或 [跳过 ci]

\n

跳过检查:true 或 跳过检查:true

\n

[跳过 azurepipelines] 或 [跳过 azurepipelines]

\n

[跳过 azpipelines] 或 [azpipelines 跳过]

\n

[跳过 azp] 或 [跳过 azp]

\n
\n

您也可以在我们的 UserVoice 网站提交功能请求。

\n