【问题标题】:How do I set up different pipelines for each branch in Azure如何为 Azure 中的每个分支设置不同的管道
【发布时间】:2020-12-09 05:11:35
【问题描述】:

我有一个项目,但有两个“主”分支。

  • 主人
  • virt/master

他们每个人都有自己的azure-pipeline.yml 特定于他们的分支。

master 中的第一个管道将触发器设置为

trigger:
  batch: true
  branches:
    include:
      - refs/heads/master

第二个在virt/master 分支中。

trigger:
  batch: true
  branches:
    include:
      - refs/heads/virt/master

这是我在 https://dev.azure.com/trajano/experiments/_git/multi-branch 上试验的存储库

我遇到的问题是,当我将更改推送到 virt/master 分支时,两个管道都会执行

我的配置中是否缺少某些内容?或者这是 Azure Devops 上的错误?

我也试过排除,但无济于事。

trigger:
  batch: true
  branches:
    include:
      - refs/heads/master
    exclude:
      - refs/heads/virt/master

【问题讨论】:

  • 也许这会让你明白:他们都应该使用 same 管道。当触发管道时,它将使用正在构建的分支中的文件版本

标签: azure-devops azure-pipelines


【解决方案1】:

如果您想拥有单独的管道,请为它们创建单独的文件定义。我认为您的配置很好,问题是您与定义共享相同的文件。

当我移到单独的文件时,它按预期工作:

【讨论】:

    【解决方案2】:

    为不同的分支创建不同的管道。您需要重命名 virt/master 分支中的 azure-pipelines.yml 文件,或者使用一些内容和 不同的名称 创建一个新的 yml 文件。并从这个新的 yml 文件创建管道 multi-branch(virt)

    如果两个管道都是从同名 azure-pipeline.yml 的 yaml 文件创建的。并且两个分支中都存在 azure-pipeline.yml 文件。那么它们是相同的管道(even though the azure-pipeline.yml file contents might be different)。

    您可以从上面的屏幕中看到。管道multi-branchmulti-branch(virt) 正在构建相同的virt/master 分支(using the tasks in the azure-pipeline.yml of virt/master)。如果你推送到主分支。您将看到两个管道都将被触发以构建主分支(using the tasks in the azure-pipeline.yml of master)。管道multi-branchmulti-branch(virt) 是一个管道

    更多信息请参见this thread

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-08
      • 2021-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-21
      • 2023-01-17
      • 1970-01-01
      相关资源
      最近更新 更多