Schedule YAML Pipeline Runs

Kyle Gibson
2 min readApr 11, 2023

--

Scenario: I wanted to schedule my YAML pipeline to run every weekday at 7:00 AM EDT, regardless if any code changes had been pushed to the main branch or not.

Attempt 1: When I added this at the top of my YAML script…

schedules:
- cron: '0 11 * * Mon,Tue,Wed,Thu,Fri'
displayName: Daily 0700 AM EDT Run
always: true

…I got this error: Invalid Schedule schema, schedule does not have usable branch filters.

Okay, no problem. Let’s add a branch filter.

Attempt 2: When I added the branch filter to my script…

schedules:
- cron: '0 11 * * Mon,Tue,Wed,Thu,Fri'
displayName: Daily 0700 AM EDT Run
branches:
include:
- main
always: true

…the pipeline automatically kicked off when any changes were merged to the main branch. If I wanted my pipeline to run on a schedule AND when code changes are merged, perhaps I would leave it like this.

But this was not the desired behavior. I wanted this pipeline to only run on the schedule specified, ignoring any changes made to the code.

Turns out, it’s a pretty simple fix.

Attempt 3: When I added the none trigger to my script…

trigger:
none

schedules:
- cron: '0 11 * * Mon,Tue,Wed,Thu,Fri'
displayName: Daily 0700 AM EDT Run
branches:
include:
- main
always: true

…the pipeline schedule worked perfectly.

That’s it!

Note: See this article more on Cron syntax: Configure schedules to run pipelines — Azure Pipelines | Microsoft Learn

Hope this helps you in your development.

Thanks for reading!

--

--

Kyle Gibson

Christian, husband, father. Data Engineer at Chick-fil-A.