简体   繁体   中英

Azure DevOps trigger pull request for only specific PR's

Use Case:
I have one GitHub repository where it is being share by multiple business units based on region. each regional business units have their own ADO pipeline created on their own ADO project but all are sharing same repository.

Problem:
Both the ADO projects used same repository, PR raised by Team-A needs to trigger Project-A ADO pipeline where currently it triggers Team-B ADO pipeline as well. which needs to be addressed.

Solution:
We need to trigger ADO pipeline for only specific Pull Requests that is specific to each regional business unit.

For pipelines triggers, you can probably use the Path filters to restrict it to the sub-folders that would be configured per region.

Several branch policies offer path filters. If a path filter is set, the policy applies only to files that match the path filter. Leaving this field blank means that the policy applies to all files in the branch.

You can specify absolute paths and wildcards. Examples:

  • /WebApp/Models/Data.cs
  • /WebApp/*
  • *.cs

You can specify multiple paths using; as a separator. Example:

  • /WebApp/Models/Data.cs;ClientApp/Models/Data.cs

Paths prefixed with. are excluded if they would otherwise be included: Example:

  • /WebApp/ ;!/WebApp/Tests/ includes all files in /WebApp except files in /WebApp/Tests
  • ,/WebApp/Tests/* specifies no files, since nothing is included first

The order of filters is significant. Filters are applied left-to-right.

For yaml pipelines, you can probably use the paths include/exclude to restrict it to the sub-folders that would be configured per region.

trigger:
  batch: true
  branches:
    include:
    - features/*
    exclude:
    - features/experimental/*
  paths:
    exclude:
    - README.md

For classic designer pipelines, you can probably use the Path filters to restrict it to the sub-folders that would be configured per region.

  • Paths are always specified relative to the root of the repository. -If you don't set path filters, then the root folder of the repo is implicitly included by default.
  • If you exclude a path, you cannot also include it unless you qualify it to a deeper folder. For example if you exclude /tools then you could include /tools/trigger-runs-on-these
  • The order of path filters doesn't matter. Paths in Git are case-sensitive. Be sure to use the same case as the real folders.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM