"Configuring the trigger failed, edit and save the pipeline again" 没有明显错误,也没有更多详细信息

"Configuring the trigger failed, edit and save the pipeline again" with no noticeable error and no further details

在将我的一堆 YAML 管道转换为使用模板来保存作业逻辑以及定义我的管道变量后,我 运行 遇到了一个奇怪的问题。管道 运行 非常好,但是我收到“最近检测到与管道触发器相关的一些问题”。管道摘要页面顶部的警告和仅查看详细信息状态:“配置触发器失败,再次编辑并保存管道。”

奇怪的是管道工作得很好,包括触发器。没有任何问题,也没有提供有关假定问题的更多详细信息。我目前为管道覆盖了 YAML 触发器,但我也在 YAML 中定义了相同的触发器以查看是否有帮助(它没有)。

鉴于 error/warning 提供的细节完全缺乏,我正在寻找有关可能导致此问题的原因或如何进一步排除故障的任何想法。它在开发人员中引起了很多混乱,他们认为警告可能导致他们的构建出现问题。

这里是主管道。构建存储库是一个共享存储库,用于保存在构建系统中跨多个存储库使用的代码。 dev.yaml 包含开发环境特定变量值。 Shared 根据管道 运行 所在的分支有条件地设置变量。

name: ProductName_$(BranchNameLower)_dev_$(MajorVersion)_$(MinorVersion)_$(BuildVersion)_$(Build.BuildId)
resources:
  repositories:
    - repository: self
    - repository: build
      type: git
      name: Build
      ref: master

# This trigger isn't used yet, but we want it defined for later.
trigger: 
  batch: true
  branches:
    include: 
    - 'dev'

variables:
- template: YAML/variables/shared.yaml@build
- template: YAML/variables/dev.yaml@build

jobs:
- template: ProductNameDevJob.yaml
  parameters:
    pipelinePool: ${{ variables.PipelinePool }}
    validRef: ${{ variables.ValidRef }}

那么这就是实际作业yaml的开始。它提供了一种可重用的作业定义,可用于多个拱形管道:

parameters:
- name: dependsOn
  type: object
  default: {}
- name: pipelinePool
  default: ''
- name: validRef
  default: ''
- name: noCI
  type: boolean
  default: false
- name: updateBeforeRun
  type: boolean
  default: false

jobs:
- job: Build_ProductName
  displayName: 'Build ProductName'
  pool:
    name: ${{ parameters.pipelinePool }}
    demands: 
    - msbuild
    - visualstudio
  dependsOn: 
  - ${{ each dependsOnThis in parameters.dependsOn }}:
    - ${{ dependsOnThis }}
  condition: and(succeeded(), eq(variables['Build.SourceBranch'], variables['ValidRef']))

  steps:
**step logic here

最后,我们有变量 YAML,它根据我们正在构建的内容有条件地设置管道变量:

variables:
- ${{ if or(eq(variables['Build.SourceBranch'], 'refs/heads/dev'), eq(variables['Build.SourceBranch'], 'refs/heads/users/ahenderson/azure_devops_build')) }}:
  - name: BranchName
    value: Dev
** Continue with rest of pipeline variables and settings of each value for each different context.

我想我可能已经找到问题所在了。这似乎与变量设置中条件的使用有关。虽然变量将在任何有效的触发器配置中设置,但在验证期间似乎没有使用正确的值,这可能是导致问题的原因。将我的条件变量切换为先设置默认值,然后有条件地替换值似乎已经解决了问题。

如果 Microsoft 能在这里提供更有用的错误消息就好了,在某种程度上是找不到给定变量的值,但添加默认值似乎确实解决了这个问题。

你可以在这里查看我的post:

正如我在你的 YAML 文件中看到的,你正在使用这个分支:'refs/heads/users/ahenderson/azure_devops_build'。

我认为您引用的一些 YAML 文件在您的构建中定义为默认的分支中丢失了:

切换到您的分支

在我们的例子中,这是因为 YAML 文件的路径以斜杠开头:/builds/build.yaml

删除斜杠修复了错误:builds/build.yaml