Lua

Lua

Certified

Tasks that run Lua scripts.

Provide Lua code inline or script files and arguments to execute via the Lua runtime in Kestra, capturing stdout/stderr and outputs.

How to use the Lua plugin

Run Lua scripts inside a container as flow steps.

Common properties

containerImage defaults to a Lua image. taskRunner defaults to Docker and can be overridden for other execution environments.

Tasks

Script runs inline Lua code defined in the script property — best for short, flow-specific logic. Commands runs shell commands (e.g., lua main.lua) against script 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.

Install LuaRocks packages in beforeCommands with luarocks install <package>, or use a custom containerImage pre-built with your dependencies.

Triggers

ScriptTrigger

Polls on an interval by running an inline Lua 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 — installing LuaRocks packages on each poll is rarely what you want; prefer an image that already has them.

Required properties:

  • script: inline Lua script body
  • exitCondition: either exit N, which matches when the script exits with code N (e.g. os.exit(1)), or a regex (with substring fallback) matched against the vars the script emits with : : {"outputs": {...}}: :

Optional:

  • interval: time between polls, defaults to PT60S
  • edge: defaults to true, 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 with trigger-edge-. Set to false to fire on every matching poll
  • containerImage: defaults to nickblah/lua

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.

CommandsTrigger

Same behavior as ScriptTrigger, but runs a list of shell commands the way the Commands task does. Required properties are commands and exitCondition; interval, edge and containerImage work as above.

See it in action