Reputation: 23
I have a repo in Devops which has a yaml pipeline that builds a jar as an artifact. The trigger on this pipeline is set to master and the override YAML CI trigger setting is unticked in the GUI. I then branched this repo to make some changes. In the branch I changed the yaml files trigger to the new branch. I was expecting any commit to this branch to trigger the pipeline and build the jar based on the code in the branch. It doesn't trigger at all. I know I can manually trigger it to run on that branch but I thought this would work to automate it. Am I missing something fundamental with how pipelines work? Is this functionality even possible?
YAML in master
trigger:
branches:
include:
- master
Using this trigger in main does trigger the build on a commit to the repo.
YAML in the branch
trigger:
branches:
include:
- <nameOfBranch>
Using this trigger with the name of the branch does not trigger the yaml when a commit is made to the branch.
Upvotes: 0
Views: 2820
Reputation: 18328
One of the nice advantages of YAML-based pipelines is that they can version with the code, so it's possible to make changes to the pipeline and have them immediately applied.
To demonstrate:
Create a pipeline that is only triggered by changes in main
. Commit the changes into a feature branch, eg feature/trigger
. When you commit changes to this branch, by design the pipeline does not automatically queue.
trigger:
branches:
include:
- main
pool:
vmImage: ubuntu-latest
steps:
- script: exit 0
Merge feature/trigger
into main
. The pipeline should automatically queue.
Create a new branch, eg feature/trigger-test
and modify the triggers to include your branch:
trigger:
branches:
include:
- main
- feature/trigger-test
Any commit to feature/trigger-test
will automatically queue pipelines.
The exception for the above is scheduled triggers. Only the default branch setting for the pipeline controls the schedule.
Important notes:
feature/trigger
and feature/Trigger
are different branches.trigger
will not match feature/trigger
feature/*
Upvotes: 0