Is it possible to create schedules using code or read from some sort of pipeline schedule definition file

anyone know of a way to create pipeline schedules using code?

background: we have a number of pipelines that all run different schedule configurations. It is a pain to update these schedules via the UI.

It would be nice I could create a definition file with all of the schedules for the pipelines and have BK read this file, that way we can commit this file into the repo and only need to update and commit a single file if we needed to tweak a schedule. Does this make sense, is this even feasible?

Welcome! And good question @ryanr

You can create and manage schedules using the graphql API so you could codify something like this. Maybe you could have a step in your default branch based builds that uses the API to set the schedules if the file is modified.
You can also use our terraform module to manage pipeline schedules which is similarly automated.

But to answer your question more directly; we don’t have an official method (other than terraform) to manage pipeline schedules using code.

I see it’s been ~2 years since this question; any chance we can specify the Schedule(s) in the pipeline YAML itself now? (We generate and upload our buildkite pipeline yaml dynamically, using the buildkite-agent pipeline upload mechanism).

Hey @mrstevegross :wave:

You aren’t able to generate schedules within Pipeline YAML itself, as was mentioned by Paula above, you can programmatically manage those schedules via GraphQL, or via the Terraform Provider.

What’s the purpose in managing schedules from your pipeline YAML? If you’re able to share some detail on what you’re wanting to accomplish, perhaps there is another way to accomplish what you’re wanting to do!

What’s the purpose in managing schedules from your pipeline YAML?

We programmatically generate pipeline YAML and upload it as part of our CI process. Since schedule is part of a pipeline, it would be great to include that as well in our upload-pipeline operation. (I suppose we could use the GraphQL endpoint, as you noted, but it’s a bit cleaner if we can express the totality of the configuration in the YAML itself). WDYT?

Hmm, I’m afraid I’m not entirely sure I’m following what you want to do here :sweat_smile:

Scheduled Builds are a way to manage when you want to have a build automatically created, with some configuration detail like branch, message, and any build environment variables. Under the hood it’s a cron job that runs on the interval configured in the schedule.

Are the YAML steps you are generating intended to modify/create a pipeline schedule?

Ideally, yes :)

Gotcha, yeah in that case using the GraphQL endpoint is going to be the best bet; though since you are already generating those steps, you could include some logic to generate a step that calls the API to create/modify those schedules based on your needs :slight_smile:

Ok, good to know. FWIW, it would be really cool to be able to include schedule in the pipeline yaml. Can y’all consider that feature request?

I’m happy to pass this along as a feature request, but just want to be transparent that it may not be picked up any time soon, if at all.

As of the time of writing (for any future travellers), our suggested way of doing this would be to use the GraphQL endpoint as above :slight_smile: