我们有一个用例,我们的代码完全托管在 Azure DevOps 中(Pipelines、Repos 等)。我们需要构建和部署“完整”构建/部署流程来部署无服务器功能。我们理想的情况是在 PR 打开和更新时有一个单一的构建/部署过程。我们有一个构建验证策略,当 PR 接受另一个 push
时,我们希望忽略 Individual CI
构建,因为 Build Validation
策略应该取代触发
block 。
由于 Azure Repos 无法使用 pr
触发器,是否有办法实现此目的?
存储库类型:Azure Repos 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
期望:仅PR自动化
构建。
这不是条件表达式本身的问题,除非有一种方法可以在 PR 中运行完整管道的同时完全禁用触发器 block 。我不认为有办法在 ADO 中运行服务器端 git hook。
最佳答案
恐怕没有这样的方法可以仅在 PR 触发器存在时禁用 CI 触发器。
在 Azure DevOps 中,CI 触发器和 PR 触发器是两个独立的触发器。如果同时满足触发条件,则管道会被触发两次。
以下是CI trigger的触发条件和 PR trigger .
但是,有一种解决方法可以实现您想要的状态。
您可以在推送更改时在提交消息中添加[skip ci]
。
然后 CI 触发器将被跳过。并且这个commit只会触发PR触发Build。
以下是equivalent commit message :
[skip ci] or [ci skip]
skip-checks: true or skip-checks:true
[skip azurepipelines] or [azurepipelines skip]
[skip azpipelines] or [azpipelines skip]
[skip azp] or [azp skip]
您也可以在 Our UserVoice site 中提交功能请求.
关于git - 在 Azure Pipelines 中,当托管在 Azure Repos 中时,是否有办法在具有开放 PR 的分支上禁用 CI?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66233684/