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?
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).
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
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?
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