Azure DevOps:YAML 延续触发器启动某些管道而不启动其他管道 - 如何调查此问题?

Azure DevOps : YAML continuation trigger starting some pipelines and not others - how to investigate this issue?

我有四个 YAML“发布”管道,我在其中使用相同的 YAML 语法来定义延续触发器。这是触发器的 YAML 定义。

resources:
  pipelines:
  - pipeline: Build  # Name of the pipeline resource
    source: BuildPipeline  # Name of the pipeline as registered with Azure DevOps
    trigger: true

不太确定这种语法,我没有指定任何分支,但直到最近一切都运行良好。最近我更新了两个 YAML 发布管道,现在它们在构建管道完成时不会被触发。如果手动执行,所有管道都可以正常工作。

所有发布管道都具有相同的 YAML 用于延续触发器定义(见上文),并且具有相同的分支集用于“手动和计划构建的默认分支”。

我不知道如何调查为什么某些发布管道未被触发(某处有可用的日志吗?)并且我没有看到它们被执行和失败,它们只是没有被触发。我该如何调查这个问题?

关于调查日志的问题 - 您可以看到创建了哪些管道运行,但遗憾的是您看不到没有创建的管道。就 Azure DevOps 而言,如果“没有发生”触发触发器,那么就没有什么可记录的。

至于管道本身不触发,从管道编辑器检查触发设置以确保那里没有设置任何东西 - UI 和 YAML 设置往往会相互抵消:

最后,如果你想指定一个分支,你可以使用以下选项的一些组合:

resources:
  pipelines:
  - pipeline: Build  # Name of the pipeline resource
    source: BuildPipeline  # Name of the pipeline as registered with Azure DevOps
    trigger:
      branches:
        include: # branch names which will trigger a build
        exclude: # branch names which will not
      tags:
        include: # tag names which will trigger a build
        exclude: # tag names which will not
      paths:
        include: # file paths which must match to trigger a build
        exclude: # file paths which will not trigger a build

我相信我发现了问题,它是从我的部署管道中删除了以下语句

pool:
  vmImage: windows-2019

我删除了这些语句,因为我将所有作业转换为如下部署作业

- deployment: MyDeployJob
  displayName: 'bla bla bla'
  environment:
    name: ${{ parameters.AzureDevopsEnv }}
    resourceType: VirtualMachine
    resourceName: ${{ parameters.AzureDevopsVM }}

没有 pool 语句的管道 运行 如果手动启动则非常好,但我确信如果通过管道完成触发器启动则无法触发。我不明白这种行为,但我将 pool 语句放回所有部署管道中,现在所有管道都在构建管道完成时被触发。

我发现在 template 中定义资源管道(触发器)时,您在 depending 管道中扩展,有两个可以阻止构建被触发的事情:

  • 模板(或父 .yaml)中存在语法错误
  • 在 Azure Devops 意识到您对其扩展的模板进行了编辑之前,需要更新依赖管道

这对我有用:

template.yaml

stages:
    - stage: SomeBuildStage
      displayName: Build The Project
      jobs:
      - job: SomeJob
        displayName: Build NuGet package from Project
        pool:
          name: My Self-hosted Agent Pool # Using Pool here works fine for me, contrary to @whatever 's answer
        steps:
          - pwsh: |
              echo "This template can be extended by multiple pipelines in order to define a trigger only once."

# I still use CI triggers as well here (optional)
trigger:
  branches:
    include:
    - '*'
    
# This is where the triggering pipeline is defined
resources:
  pipelines:
    - pipeline: trigger-all-builds # This can be any string
      source: trigger-all-builds # This is the name defined in the Azure Devops GUI
      trigger: true

depending-pipeline.yaml

extends:
  template: template.yaml

# I still use CI triggers as well here (optional)
trigger:
  paths:
    include:
      - some/subfolder

triggering-pipeline.yaml

stages:
  - stage: TriggerAllBuilds
    displayName: Trigger all package builds
    jobs:
      - job: TriggerAllBuilds
        displayName: Trigger all builds
        pool:
          name: My Self-hosted Agent Pool
        steps:
          - pwsh: |
              echo "Geronimooo!"
            displayName: Geronimo

trigger: none
pr: none