Azure Pipeline 使用 YAML 触发 Pipeline [英] Azure Pipeline to trigger Pipeline using YAML

查看:170
本文介绍了Azure Pipeline 使用 YAML 触发 Pipeline的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在使用 YAML 完成另一个管道时触发 Azure 管道.有 documentation 表明您可以添加管道资源:

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.

推荐答案

用于触发来自另一个 azure 官方的一个管道 docs 建议以下解决方案.即使用管道触发器

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.所以在这个场景中,B 运行了 2 次,一次是在你提交时(与 A 并行),第二次是在 A 完成之后.

But actually what happens, is that it triggers two pipelines. Take an example, let suppose we have two pipelines A and B and we want to trigger B when A finishes. So in this scenario B runs 2 times, once when you do a commit (parallel with A) and second after A finishes.

为了避免这个管道两次运行问题,请遵循以下解决方案

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 Pipeline 使用 YAML 触发 Pipeline的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆