I’m trying to run pipelines against a repo using a nightly schedule. I would like to run different pipelines at different times, however I am coming up short as to how to distinguish them. I can pass the DRONE_BUILD_EVENT variable in to determine that this is a cron event, but I want to have a couple of different cron jobs that run where different actions are taken. I see that you can name the cron jobs when using the cli/api. Is the cron name available in an environment variable for the pipeline to use? Are there any other ways that you can provide to accomplish this?
you can specify that a pipeline should only execute for a named cron job using the trigger block:
https://docs.drone.io/pipeline/docker/syntax/trigger/#by-cron
or you can specify that individual steps should only execute for a named cron job using the when block:
https://docs.drone.io/pipeline/docker/syntax/conditions/#by-cron
the name of the cron job is also available to your pipeline steps via the DRONE_BUILD_TRIGGER
environment variable.
Thanks for the info, Brad. I was playing around with this and I’ve found that the DRONE_BUILD_TRIGGER environment variable is always blank for cron jobs with names. I’m going to pursue the when/trigger block, but wanted to follow up on the DRONE_BUILD_TRIGGER environment variable. I didn’t find this anywhere in the docs either. Do I need to be at a specific version or any other requirements for this value to be present?
Thanks again!