Azure管道:在根级别对文件进行文件触发

问题描述

如何在根级别将所有文件添加为Azure Devops-Pipeline的触发器?

当前我的设置如下:

pr:
  branches:
    include:
      - '*'
  paths:
    include:
      - '*' # this matches all files in the repository
      - apps/*

旨在通过更改根目录级文件(即package.json)和应用程序文件夹中的文件来触发pr构建。但是,包含*会匹配存储库中的所有文件,而不是根目录文件

documentation不能帮助我。有没有一种方法可以将所有根目录文件都包含到触发器中,而无需手动包含每个文件

解决方法

如果仅希望根目录中的更改触发管道,则需要排除exclude部分中的所有文件夹:

pr:
 branches:
   include:
     - master
 paths:
   include:
     - '*'
   exclude:
     - 'stackoverflow/*'
     - 'abc/*'
     - 'xyz/*'
,

这里同意Krzysztof Madej '*' # same as '/' for the repository root的观点,这里是您可以参考的document。如果您不希望根目录中文件夹的子文件触发管道,则需要向exclude过滤器中添加paths

例如:

trigger:
      branches:
        include:
         - master
      paths:
        include:
         - '*'
        exclude:
          - '/test01/'

enter image description here

然后对test0文件所做的更改将不会触发管道。