Drone ci cron job

Hello,
In the doc (https://docs.drone.io/), the infomation of cron job is not clear.
I want to create a cron job, but it do not work. The yaml configs is:

Can you give me a clear example.

Hi @chen-s-f you might find this helpful.

Basically, what you need is something like this.

you basically need to use this command: curl -X POST -H "Authorization: Bearer $DRONE_TOKEN" "$DRONE_SERVER/api/repos/foo/bar/cron/every-5-mins"

In simple words:

  1. cron jobs are defined in the user interface (settings screen) or using the command line tools. They are not defined in the yaml, although you can limit which pipelines or pipeline steps are executed by named cron jobs. For more information please see https://docs.drone.io/cron/
  2. the trigger section would specify the name of the existing cron jobs, not the cron expression syntax
  3. the cron expression syntax must include seconds (6 space-separated fields) as shown in the documentation

Hope this helps!

Thanks

Hi Shruthikini,
I tried to add cron job in the UI,such as


But how to add the job in yaml can you give me a example, in the doc( https://docs.drone.io/cron/ ) the describe is not clear.
Thank you !

Hi Shruthikini,

  1. the trigger section would specify the name of the existing cron jobs, not the cron expression syntax
    –Can you give me a yaml example in drome.yaml?
    Thank you !

@chen-s-f say if you have a sample drone file like this:

kind: pipeline
type: kubernetes
name: default

  - name: echo-hello
    image: alpine
    commands:
      - echo "hello"
    when:
      event:
        - push

  - name: echo-goodbye
    image: alpine
    commands:
      - echo "goodbye"
    when:
      event:
        - push

You should add it in this way. Trigger mean that this whole pipeline will run only when cron runs it.

event: 
  - cron
cron:
  - hourly 

to when: for each section.