Azure管道使用YAML触发管道 [英] Azure Pipeline to trigger Pipeline using YAML
问题描述
尝试使用YAML完成另一个管道时触发Azure管道. 文档指示您可以添加具有以下内容的管道资源:
Attempting to trigger an Azure pipeline when another pipeline has been completed using a YAML. There's documentation indicating that you can add a pipeline resource with:
resources: # types: pipelines | builds | repositories | containers | packages
pipelines:
- pipeline: string # identifier for the pipeline resource
connection: string # service connection for pipelines from other Azure DevOps organizations
project: string # project for the source; optional for current project
source: string # source defintion of the pipeline
version: string # the pipeline run number to pick the artifact, defaults to Latest pipeline successful across all stages
branch: string # branch to pick the artiafct, optional; defaults to master branch
tags: string # picks the artifacts on from the pipeline with given tag, optional; defaults to no tags
但是,我一直无法弄清楚来源"是什么意思.例如,我有一个名为myproject.myprogram
的管道:
However, I've been unable to figure out what the "source" means. For example, I have a pipeline called myproject.myprogram
:
resources:
pipelines:
- pipeline: myproject.myprogram
source: XXXXXXXX
此外,目前尚不清楚如何基于此来创建触发器.
Moreover, it's unclear how you'd build based a trigger based on this.
我知道可以通过Web GUI完成此操作,但是应该可以通过YAML做到这一点.
I know that this can be done from the web-GUI, but it should be possible to do this from a YAML.
推荐答案
For trigger of one pipeline from another azure official docs suggest this below solution. i.e. use pipeline triggers
resources:
pipelines:
- pipeline: RELEASE_PIPELINE // any arbitrary name
source: PIPELINE_NAME. // name of the pipeline shown on azure UI portal
trigger:
branches:
include:
- dummy_branch // name of branch on which pipeline need to trigger
但是实际上发生的是它触发了两个流水线,例如,假设我们有两个流水线A和B,而我们想在A完成时触发B.所以 在这种情况下,当您执行commit(与A并行)时,B运行2次,而在A完成之后运行2次.
But actually what happen is that it trigger two pipeline like take an example let suppose we have two pipeline A and B and we want to trigger B when A finish. so in this scenario B run 2 times one when you do a commit( parallel with A) and second after A finish .
因此,为避免出现两次管道运行问题,请遵循以下解决方案
trigger: none // add this trigger value to none
resources:
pipelines:
- pipeline: RELEASE_PIPELINE // any arbitrary name
source: PIPELINE_NAME. // name of the pipeline shown on azure UI portal
trigger:
branches:
include:
- dummy_branch // name of branch on which pipeline need to trigger
通过添加 trigger:none ,第二个管道将不会在开始提交时触发,而只会在第一次完成其工作时触发.
by adding trigger:none second pipeline will not trigger at start commit and only trigger when first finish its job.
希望这会有所帮助.
这篇关于Azure管道使用YAML触发管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!