
JBang
CertifiedTasks that run Java code with JBang.
Provide Java code inline or source files with dependencies and JBang options to compile and run via JBang from Kestra, capturing outputs for downstream steps.
JBang
Tasks that run Java code with JBang.
Provide Java code inline or source files with dependencies and JBang options to compile and run via JBang from Kestra, capturing outputs for downstream steps.
tasks
triggers
How to use the JBang plugin
Run Java source files directly without a build system — JBang compiles and executes them on the fly.
Common properties
containerImage defaults to a JBang image. taskRunner defaults to Docker and can be overridden for other execution environments.
Tasks
Script runs inline Java code defined in the script property — best for short, flow-specific logic. Commands runs JBang commands (e.g., jbang main.java) against source files; use it when your code lives in namespace files shared across flows, or is cloned from a Git repository with a preceding Clone task.
Declare Maven dependencies directly in the source file using JBang's //DEPS directive at the top: //DEPS com.google.guava: guava: 32.0.0-jre. JBang resolves and caches them automatically at runtime — no pom.xml or build.gradle required.
Triggers
ScriptTrigger
Polls on an interval by running an inline JBang script the same way the Script task does, and starts an execution when exitCondition matches. The script runs in a fresh container on every poll, so keep it quick.
Required properties:
script: inline JBang script bodyexitCondition: eitherexit N, which matches when the script exits with code N, or a regex (with substring fallback) matched against the vars the script emits with: : {"outputs": {...}}: :
Optional:
interval: time between polls, defaults toPT60Sedge: defaults totrue, so the trigger fires only when the condition changes from not matching to matching. The previous result is kept in the namespace KV store under a key starting withtrigger-edge-. Set tofalseto fire on every matching pollcontainerImage: defaults tojbangdev/jbang-actionextension: file extension for the inline script (.java,.jsh,.kt,.groovy,.md), defaults to.java. Because each poll runs in a fresh container without a cached JBang environment,.ktand.groovyscripts incur a compiler cold start (around 25-30s) on every poll, so sizeintervalaccordinglyquiet: runs JBang with--quiet, defaults totrue
The trigger outputs are available as {{ trigger.timestamp }}, {{ trigger.condition }}, {{ trigger.exitCode }} and {{ trigger.vars }}. A failed run has no vars, so only an exit N condition can match a failure. Since JBang itself exits with 1 on compile errors or unresolvable //DEPS, prefer a dedicated exit code such as exit 42 for the condition you watch.
CommandsTrigger
Same behavior as ScriptTrigger, but runs a list of commands the way the Commands task does. Required properties are commands and exitCondition; interval, edge and containerImage work as above.