Python CommandsTrigger

Python CommandsTrigger

Certified

Trigger on Python commands condition

Polls by running Python commands (default image python: 3.13-slim) and emits when exitCondition matches. Supports edge mode to emit only on transitions and polls every 60s by default. Accepts 'exit N' or a regex (fallback substring) matched against emitted vars and failure logs.

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

Trigger when the Python command fails with exit code 1.

yaml
id: python_commands_trigger
namespace: company.team

triggers:
  - id: on_fail
    type: io.kestra.plugin.scripts.python.CommandsTrigger
    interval: PT10S
    exitCondition: "exit 1"
    edge: true
    containerImage: python:3.13-slim
    commands:
      - python3 -c "raise Exception('boom')"

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

Python commands to execute

Commands executed on each poll (same semantics as the Python Commands task).

Defaultfalse

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

Defaultpython:3.13-slim

Docker image used to execute the commands

Container image used by the underlying Commands task to run Python commands. Defaults to 'python: 3.13-slim'.

Defaulttrue

Edge trigger mode

If true (default), the trigger emits only on a transition from 'not matching' to 'matching' (anti-spam). If false, the trigger emits on every poll where the condition matches.

Condition to match

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": ...}::) and failure logs.

DefaultPT1M
Formatduration

Check interval

Interval between polling evaluations.

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.

Exit code

Exit code returned by the Python 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).