In Azure DevOps, created pipeline using Yaml file and mentioned "develop" under Triggers section. It is triggering for new commits in develop branch but also triggering for new branch creation based on "develop" branch which is not happening when I create a static pipeline. How can I prevent build for new branch. Any help here?
Asked
Active
Viewed 493 times
3 Answers
0
I think you should use the include / exclude filters like below :
# this is being defined in app-ci pipeline
resources:
pipelines:
- pipeline: securitylib
source: security-lib-ci
trigger:
branches:
include:
- releases/*
exclude:
- releases/old*
Just check this page and you should find your answer : https://learn.microsoft.com/en-us/azure/devops/pipelines/process/pipeline-triggers?view=azure-devops
Regards

Alexandre Castro
- 101
- 4
-
Hello Alexandre, I tried that but still pipeline is triggering for new branch creation. See my code below trigger: branches: include: - refs/heads/develop batch: True name: $(date:yyyyMMdd)$(rev:.r) resources: repositories: - repository: self type: git ref: refs/heads/develop – Vinod Feb 08 '22 at 04:41
-
I think you should only include th branch you want to trigger and exclude all others like : include: - refs/heads/develop exclude: - refs/heads/* – Alexandre Castro Feb 09 '22 at 06:52
-
After using include: refs/heads/develop alone it is working fine. Thank you – Vinod Feb 09 '22 at 14:11
-
Can you add +1 and mark as resolved please ? – Alexandre Castro Feb 10 '22 at 07:04
0
Starting from 2020 or 2021 this is possible. Just put a Path filter in your yaml:
trigger:
paths:
include:
- /
For example in my pipeline yaml definition I use this:
trigger:
batch: true
branches:
include:
- feature/*
paths:
include:
- /
If you use old classic pipelines, the answer is always Path filters. You can see here how.

Gioce90
- 554
- 2
- 10
- 31