JBang ScriptTrigger

JBang ScriptTrigger

Certified

Trigger on JBang script condition

Polls by running an inline JBang script in a container (default image jbangdev/jbang-action) and emits when exitCondition matches. Edge mode (the default) emits only on a transition from not matching to matching, remembering the previous result in the namespace KV store. Polls every 60s by default. Accepts 'exit N' or a regex (fallback substring) matched against emitted vars; a failed run has no vars, so only 'exit N' can match a failure.

yaml
type: io.kestra.plugin.scripts.jbang.ScriptTrigger

Trigger when the script fails with a specific exit code (exit 42).

yaml
id: script_trigger
namespace: company.team

triggers:
  - id: script_failure
    type: io.kestra.plugin.scripts.jbang.ScriptTrigger
    interval: PT60S
    exitCondition: "exit 42"
    edge: true
    containerImage: jbangdev/jbang-action
    script: |
      class Check {
          public static void main(String[] args) {
              System.exit(42);
          }
      }

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

Condition to match

Rendered condition evaluated after each execution; the trigger emits only when it matches. 'exit N' compares the exit code, otherwise the string is used as a regex (or substring fallback) against emitted vars (from ::{"outputs": ...}::). On a failed run no vars are available to match against, so only an 'exit N' condition can match a failure. Note that JBang itself exits with 1 on compile errors and unresolvable //DEPS, so prefer a dedicated exit code (e.g. 'exit 42') for the condition you watch.

Inline JBang script

Multi-line script executed on each poll, with the same semantics as the JBang Script task.

Defaultfalse

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

Defaultjbangdev/jbang-action

Container image for script execution

Image used by the Script task to run the inline JBang script; defaults to 'jbangdev/jbang-action'. Provide an image that includes JBang.

Defaulttrue

Edge trigger mode

When true (default), emit only on a transition from not matching to matching, so a condition that stays true does not fire on every poll. The previous result is kept in the namespace KV store, keyed by flow and trigger id. When false, emit on every poll that matches.

Default.java

Script extension

File extension to write (e.g., .java, .jsh, .kt, .groovy, .md); defaults to .java. Note that each poll starts a fresh container without a JBang cache, so .kt and .groovy scripts incur a compiler cold start (around 25-30s) on every poll.

DefaultPT1M
Formatduration

Check interval

Interval between polls; default PT60S. The scheduler uses this to schedule the next evaluation.

Defaulttrue

Quiet mode

When true (default), runs JBang with --quiet to suppress non-error logs.

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 value of the exitCondition property for this poll.

Script exit code

Exit code returned by the JBang process (may be null if not available).

Formatdate-time

Timestamp of the event that fired the trigger

Script vars

Vars produced by the task (e.g. via ::{"outputs": {...}}:: convention). This is the main structured way to evaluate non-exit conditions on successful runs.