Groovy CommandsTrigger

Groovy CommandsTrigger

Certified

Trigger a flow when Groovy commands match a condition

Runs its own Groovy commands on an interval through the Commands task and starts a flow when exitCondition matches. Defaults to the groovy container image and a 60-second interval.

yaml
type: io.kestra.plugin.scripts.groovy.CommandsTrigger

Trigger when a Groovy command exits with code 1.

yaml
id: groovy_commands_trigger
namespace: company.team

tasks:
  - id: log
    type: io.kestra.plugin.core.log.Log
    message: "Triggered with exitCode={{ trigger.exitCode }}"

triggers:
  - id: poll
    type: io.kestra.plugin.scripts.groovy.CommandsTrigger
    interval: PT60S
    exitCondition: "exit 1"
    commands:
      - groovy -e "System.exit(1)"
Properties
SubTypestring

Groovy commands

Executed on each poll with the same command rendering semantics as the Groovy Commands task, including runner variables such as workingDir. beforeCommands, env and taskRunner are not exposed by this trigger. Supply dependencies and configuration in the commands (for example @Grab in Groovy code, which may require network access) or container image.

Condition to match

Evaluated after each run. 'exit N' compares a known process exit code (case insensitive). Other nonempty values are regexes matched against structured vars emitted using ::{"outputs": {...}}::. Invalid or excessive regexes fall back to substring matching. Raw stdout and stderr are not matched.

Defaultfalse

Specifies whether a trigger is allowed to start a new execution even if a previous run is still in progress.

Defaultgroovy

Container image

Image used by the underlying Groovy task on each poll. Defaults to groovy.

Defaulttrue

Edge trigger mode

When true (default), the first matching poll emits and consecutive matches are suppressed until a nonmatching poll. The last match state is stored in the flow namespace KV store, scoped to this flow and trigger. When false, each fresh matching run emits without accessing or updating KV state. Re-enabling edge mode resumes the last stored edge-mode state. This does not provide exactly-once delivery if an evaluation crashes.

DefaultPT1M
Formatduration

Check interval

Interval between fresh executions of the configured script or commands. Defaults to PT60S.

SubTypestring
Possible Values
CREATEDSUBMITTEDRUNNINGPAUSEDRESTARTEDKILLINGSUCCESSWARNINGFAILEDKILLEDCANCELLEDQUEUEDRETRYINGRETRIEDSKIPPEDBREAKPOINTRESUBMITTED

List of execution states after which a trigger should be stopped (a.k.a. disabled).

Defaulttrue

A condition that determines whether the trigger should run.

A Pebble expression evaluated at trigger time. The trigger fires only when the expression evaluates to a truthy value (true, a non-empty string, a non-zero number). Use this to gate trigger execution on dynamic runtime values such as execution labels, flow variables, or environment conditions.

Rendered condition

Rendered exitCondition for this poll.

Process exit code

Groovy task exit code, or null when unavailable. Unknown codes never match 'exit N'.

Formatdate-time

Poll timestamp

Time the Groovy task finished for this poll.

Structured script vars

Values emitted by the task using ::{"outputs": {...}}::, including values emitted before a process failure.