CronTrigger

JFrog Pipelines Documentation

ft:sourceType
Paligo

A CronTrigger is used as an inputResource to a step to trigger execution of the step at a scheduled time or at a recurring interval. The minimum recurring interval for CronTrigger is one minute and it supports the cron syntaxand UTC time.

YAML Schema
resources:
  - name:               <string>
     type:              CronTrigger
     configuration:
       interval:    <string>  # should be a cron expression
       branches:
         include: "^dev.+$" <string>
         exclude: "^dev-test.+$" <string>
       environmentVariables:
         key: value
         key: value
Tags
name

An alphanumeric string (underscores are permitted) that identifies the resource.

type

Must be CronTrigger for this resource type.

configuration

Specifies all configuration selections for the resource.

Tag

Description

Required/Optional

interval

A cron expression string that specifies the time(s) or interval to trigger the step.

The interval tag uses standard Cron expression and takes the following format:

Format

interval: * * * * *                                 
          │ │ │ │ │_________ day of the week (1-7 or SUN-SAT)
          | | | |__________ month (1 - 12)
          | | |__________ day of the month (1 - 31)
          | |__________ hour (0 - 23)
          |__________ minute (0 - 59)

Examples

CRON Expression

Meaning

0 12 * * *

12 PM (noon) every day.

25 10 * * *

10:25 AM every day.

15 22 * * *

10:15 PM every day.

* 16 * * *

Every minute starting at 4 PM and ending at 4:59 PM, every day.

0/5 13 * * *

Every 5 minutes starting at 1 PM and ending at 1:55 PM, every day.

0/5 15,18 * * *

Every 5 minutes starting at 3 PM and ending at 3:55 PM, and every 5 minutes starting at 6 PM and ending at 6:55 PM, every day.

0-5 18 * * *

Every minute starting at 6 PM and ending at 6:05 PM, every day.

10,44 15 * 5 MON

3:10 PM and at 3:44 PM every Monday in the month of May.

45 10 * * MON-FRI

10:45 AM every Monday, Tuesday, Wednesday, Thursday and Friday.

30 10 10 * *

10:30 AM on the 10th day of every month.

0 12 1/5 * *

12 PM (noon) on every 5th day-of-month from 1 through 31.

11 11 11 11 *

Every November 11th at 11:11 AM.

Note

  • For more information, see Cron expression.

  • It is recommended that you first test your Cron expression using an online tool before using it.

Required

branches

For use in multibranch pipelines, though it will also work with single branch pipelines. An object where include and exclude regex patterns are used to control which branches are triggered by the resource.

  • If an include pattern is supplied, any branch not matching the pattern will not trigger.

  • If an exclude pattern is supplied, any branch matching the pattern will not trigger.

Note

When include or exclude is not provided, the cronTrigger resource will trigger every branch in a multibranch pipeline. Most multibranch pipelines should use this configuration.

Optional

environmentVariables

Add environment variables as key-value pairs.

Example

    configuration:
      interval: '*/30 * * * *' # Every 10 minutes
      environmentVariables:
        first: env
        second: env

Environment Variables

Whenever CronTriggeris used in a step, a set of environment variables is automatically made available that you can use in your step.

Environment Variable

Description

res_<resource_name>_name

Name of the resource

res_<resource_name>_interval

The cron string that specifies the time(s) or interval

Examples

The Pipelines DSL for this example is available in this repository in the JFrog GitHub account.

resources:
  - name: cron_trigger
    type: CronTrigger
    configuration:
      interval: '*/5 * * * *'     # Every 5 minutes
      branches:
        include: "^dev.+$"
        exclude: "^dev-test.+$"
      environmentVariables:
        first: env
        second: env

pipelines:
  - name: pipeline_scheduled_triggers
    steps:
      - name: step_1
        type: Bash
        configuration:
          inputResources:
            - name: cron_trigger
        execution:
          onExecute:
            - printenv