Question: Filtering scheduled pipelines by branch name #103
Description
Hello, I'm digging through the new scheduled pipelines feature documentation.
When converting from the old scheduled workflows syntax, I noticed that there doesn't seem to be an equivalent way to ensure that scheduled pipelines only trigger for specific branches.
Old trigger:
daily-run-workflow:
triggers:
- schedule:
# Every day, 0421Z.
cron: "21 4 * * *"
filters:
branches:
only:
- main # <-- Only run on the main branch
jobs:
- test
- build
But there doesn't seem to be an equivalent way to filter workflows by branch name:
daily-run-workflow:
when:
and:
- equal: [ scheduled_pipeline, << pipeline.trigger_source >> ]
- equal: [ "my schedule name", << pipeline.schedule.name >> ]
# Missing mechanism to filter by branch name
jobs:
- test
- build
I hope I'm not misunderstanding how scheduled pipelines work with respect to branches, but please correct me if that's the case.
Is there an existing way to filter on branch name? Maybe something like:
daily-run-workflow:
when:
and:
- equal: [ scheduled_pipeline, << pipeline.trigger_source >> ]
- equal: [ "my schedule name", << pipeline.schedule.name >> ]
- equal: [ "main", << pipeline.branch.name >> ] # <-- only match when pipeline.branch.name equals "main"
Or is this on the development roadmap?
Scheduled pipelines look like a very cool feature, I'm looking forward to fully utilizing them! Thank you!
Edit: Fixed YAML syntax and reworded a bit for clarity.