Create and configure triggers
Here are the steps to create and configure triggers via code:-
Create a
triggers.yamlfile under your pipeline folder. The file path should bepipelines/[pipeline_uuid]/triggers.yaml. -
Enter your trigger configs into the
triggers.yamlfile.- Content structure
- Required trigger fields
name: Unique identifier of the triggerschedule_type:time,api, oreventschedule_interval:@once,@hourly,@daily,@weekly,@monthly,@always_on, or Cron syntax(* * * * *)start_time: The start time of the trigger (e.g.2023-01-01)
- Optional trigger fields
status:activeorinactivevariables: A dictionary of variables that’s associated with the triggersla: SLA in secondssettings: a dictionary of advanced settingsskip_if_previous_running:true/falseallow_blocks_to_fail:true/falsecreate_initial_pipeline_run:true/false
envs: The environments that the trigger runs in.- If
envsis not set or empty, the trigger will run in all environments. - The environment of the Mage app is set via the
ENVenvironment variable. - OSS: Only supports
dev,staging,prod,test. - Mage Pro: Supports any value, which must match the
ENVenvironment variable.
- If
- Content structure
-
Save the
triggers.yamlfile. The trigger configs will be synced to the triggers UI shortly.
Example triggers config:
Modify triggers
If an existing trigger is configured in the yaml file, any updates to it through the UI will also update trigger config in the yaml file. If you modify the trigger settings directly in the yaml, it will automatically update the trigger in the UI. The new trigger configs are synced to the triggers in UI.Delete triggers
Thetriggers.yaml file is synced into the database automatically, but deletions work differently:
-
Deleting triggers completely:
Removing a trigger from the yaml file won’t delete it from the database. You will need to delete the trigger in the UI.
- In the Pipeline triggers table (
/pipeline/[pipeline_uuid]/triggers), click the trash can icon. - In Mage Pro, right-click on the trigger row and click Delete.
triggers.yamlconfig file. - In the Pipeline triggers table (
-
Alternative to deletion:
Instead of deleting, you can update the trigger status in the yaml file (e.g. set
status: inactive). Status changes are automatically synced to the database and UI.