0

我有一个包含 2 个目录的存储库,一个带有 python 代码,一个带有 C 代码。仅当 python 文件夹(hello_app)中的文件发生更改时,我才想在所有 PR 上运行一个管道。我使用了以下 yaml 文件,但当新 PR 包含 hello_app 目录之外的更改(仅)时,管道仍会运行:

trigger:
- none

pr:
  branches:
    include:
    - master
  paths:
    exclude:
    - '*'
    include:
    - hello_app/*

pool:
  vmImage: 'ubuntu-latest'
strategy:
  matrix:
    Python27:
      python.version: '2.7'
    Python36:
      python.version: '3.6'

steps:
- task: UsePythonVersion@0
  inputs:
    versionSpec: '$(python.version)'
  displayName: 'Use Python $(python.version)'

- script: |
    python -m pip install --upgrade pip
    pip install -r requirements.txt
  displayName: 'Install dependencies'

- script: |
    python -m pip install flake8
    flake8 .
  displayName: 'Run linter tests'

- script: |
    pip install pytest pytest-azurepipelines
    pytest
  displayName: 'pytest'

我试图在线搜索,但似乎这应该工作。我使用的 yaml 有问题吗?

4

1 回答 1

1

请参阅此文档

YAML PR 触发器仅在 GitHub 和 Bitbucket Cloud 中受支持。如果使用 Azure Repos Git,则可以配置用于生成验证的分支策略,以触发生成管道进行验证。

如果您使用的是 Azure 存储库,则需要为生成验证配置分支策略以触发生成管道进行验证。

您可以导航到branch policy -> build validation 并设置路径过滤器(/hello_app/*)。

这是我的例子:

在此处输入图像描述

然后它可以按预期工作。

于 2020-10-15T06:29:06.940 回答