Trigger jobs with resource
The primary way that Concourse jobs will be triggered to run will be by resources changing. Agit
repo has a new commit? Run a job to test it. A GitHub project cuts a new release? Run a job to pull down its attached files and do something with them.
Triggering resources are defined the same as non-triggering resources, such as theresource-tutorial
defined earlier.
The difference is in the job build plan where triggering is desired.
By default, includingget: my-resource
in a build plan does not trigger its job.
To mark a fetched resource as a trigger addtrigger: true
jobs-
jobs:
- name: job-demo
plan:
- get: resource-tutorial
trigger: true
In the above example thejob-demo
job would trigger anytime the remoteresource-tutorial
had a new version. For agit
resource this would be new git commits.
Thetime
resource has express purpose of triggering jobs.
If you want a job to trigger every few minutes then there is thetime
resource.
resources:
- name: my-timer
type: time
source:
interval: 2m
Now upgrade thehelloworld
pipeline with thetime
trigger.
cd ../08_triggers
fly set-pipeline --target tutorial --config pipeline.yml --pipeline helloworld
This adds a new resource namedmy-timer
which triggersjob-hello-world
approximately every 2 minutes.