.NET (C#) ScriptTrigger

.NET (C#) ScriptTrigger

Certified

Trigger a flow when a C# script matches a condition

Polls by running an inline C# script in a .NET SDK container and emits when exitCondition matches.

The common polling, edge-state, condition matching, and failure handling behavior is provided by AbstractDotnetTrigger.

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

Trigger when the C# script fails with an implicit error (exit 1).

yaml
id: script_trigger
namespace: company.team

triggers:
  - id: script_failure
    type: io.kestra.plugin.scripts.csharp.ScriptTrigger
    interval: PT60S
    exitCondition: "exit 1"
    edge: true
    containerImage: mcr.microsoft.com/dotnet/sdk:10.0
    script: |
      System.Environment.Exit(1);

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

Inline C# script

Multi-line C# script executed on each poll. The script is executed using the C# Script task.

Defaultfalse

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

Defaultmcr.microsoft.com/dotnet/sdk:10.0

Container image for task execution

Container image used to execute the underlying .NET task. Defaults to 'mcr.microsoft.com/dotnet/sdk: 10.0'.

Defaulttrue

Edge trigger mode

When true (default), emit only on a transition from not matching to matching. The previous result is stored in the namespace KV store using the flow and trigger identity.

When false, emit on every matching poll.

Condition to match

Condition evaluated after each polling execution.

Supported forms:

  • 'exit N' matches the task exit code.
  • Any other string is treated as a regex, with substring fallback, against values emitted by the task.

A failed task has no output vars, so only an 'exit N' condition can match a failure.

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).

DefaultAUTO
Possible Values
LINUXWINDOWSAUTO

Target operating system

Operating system used by the underlying .NET task.

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.