Kamsiinov
Kamsiinov

Reputation: 1490

Azure DevOps defining path filter to yml build file

My project structure is like

/AzureStuff/AzureAA/Source/

/AzureStuff/AzureBB/Source/

/AzureStuff/AzureCC/Source/

And my build definition:

name: $(BuildDefinitionName)
resources:
- repo: self
queue:
  name: AzureBuild
trigger:
  batch: true
  paths:
    include:
    - /AzureStuff/AzureAA/Source/*
steps:
- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: AzureAA'
  inputs:
    PathtoPublish: AzureStuff/AzureAA/Source
    ArtifactName: AzureAA

However, when I commit my sources into the /AzureStuff/AzureAA/Source/ my build does not run. Only the builds for BB and CC runs because they do not have path filter. How should I change my path filter to make the AA build work? I am planning on having path filters on every build.

Upvotes: 7

Views: 16590

Answers (2)

Mike
Mike

Reputation: 471

You're missing your branch filter

When you specify paths, you must explicitly specify branches to trigger on. You can't trigger a pipeline with only a path filter; you must also have a branch filter

https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/azure-repos-git?view=azure-devops&tabs=yaml&WT.mc_id=AZ-MVP-5003781#paths

trigger:
  branches:
    include:
    - master
  paths:
    include:
    - AzureStuff/AzureAA/Source/

Upvotes: 5

4c74356b41
4c74356b41

Reputation: 72191

path triggers have to be relative to the root of the repo, just like the docs mention (and the very first comment):

trigger:
  batch: true
  paths:
    include:
    - AzureStuff/AzureAA/Source

Upvotes: 9

Related Questions