Search code examples
crondrone.io

Drone Cron Job Not Firing


I've created a cron job in Drone CI using the following command

drone cron add --branch master "foo/bar" "every-5-mins" "0 */5 * * * *"

And when I look in the UI, I can see the cron job has been created. However, it doesn't fire, even though I have it defined in my drone yaml file.

- name: cron-job
  pull: if-not-exists
  image: foo-image
  commands:
    - *random
    - echo "I am testing a cron job"
  when: &cron-demo
    event:
      - cron
    cron:
      - every-5-mins

Does something else need to be done to get it to work on schedule?

And also, is there a way to manually trigger a cron job? I can't seem to find anything in the docs.


Solution

  • You might find this helpful.

    https://docs.drone.io/api/cron/cron_trigger/

    Basically, what you need is something like this.

    curl -X POST -H "Authorization: Bearer $DRONE_TOKEN" "$DRONE_SERVER/api/repos/foo/bar/cron/every-5-mins"