Skip to main content

Run

Provides the capability to run execute external commands

Properties

NameTypeRequiredDescription
run.containercontainernoThe definition of the container to run.
Required if script, shell and workflow have not been set.
run.scriptscriptnoThe definition of the script to run.
Required if container, shell and workflow have not been set.
run.shellshellnoThe definition of the shell command to run.
Required if container, script and workflow have not been set.
run.workflowworkflownoThe definition of the workflow to run.
Required if container, script and shell have not been set.
awaitbooleannoDetermines whether or not the process to run should be awaited for.
When set to false, the task cannot wait for the process to complete and thus cannot output the process’s result. Only available for workflows.
Defaults to true.

Container

info

Currently, this only supports Docker containers run via the docker binary on your local machine. Additional container runtimes are planned - please upvote #181 to influence prioritsation.

Enables the execution of external processes encapsulated within a containerised environment, allowing workflows to interact with and execute complex operations using containerised applications, scripts, or commands.

Properties

NameTypeRequiredDescription
imagestringyesThe name of the container image to run
namestringnoA runtime expression, if any, used to give specific name to the container. Uses a UUID if not set.
commandstringnoThe command, if any, to execute on the container
portsmapnoThe container's port mappings, if any
volumesmapnoThe container's volume mappings, if any
environmentmapnoA key/value mapping of the environment variables, if any, to use when running the configured process
argumentsstring[]noA list of the arguments, if any, passed as argv to the command or default container CMD
lifetimecontainerLifetimenoAn object used to configure the container's lifetime

Example

document:
dsl: 1.0.0
namespace: zigflow
name: example
version: 0.0.1
do:
- container:
run:
container:
image: alpine
arguments:
- env
environment:
hello: world

Container Lifetime

Configures the lifetime of a container.

Properties

PropertyTypeRequiredDescription
cleanupstringyesThe cleanup policy to use.
Supported values are:
- always: the container is deleted immediately after execution.
- never: the runtime should never delete the container.

Defaults to always.

Script

Enables the execution of custom scripts or code within a workflow, empowering workflows to perform specialised logic, data processing, or integration tasks by executing user-defined scripts written in various programming languages.

Properties

NameTypeRequiredDescription
languagestringyesThe language of the script to run.
Supported values are: js and python.
codestringyesThe script's code.
argumentsstring[]noA list of the arguments, if any, to the script as argv
environmentmapnoA key/value mapping of the environment variables, if any, to use when running the configured script process

Supported languages

warning

The Docker image is built on the node:lts-alpine image and installs the python3 Alpine package. For specific versions of these languages, build your own image.

This is a list of available languages and the command that is called.

LanguageBinary Target
jsnode
pythonpython

Example

document:
dsl: 1.0.0
namespace: zigflow
name: example
version: 0.0.1
do:
- nodejs:
export:
as: '${ $context + { nodejs: . } }'
run:
script:
language: js
code: |
const http = require('http');

console.log(`${process.argv[2]} from ${process.env.NAME}`);

console.log(http.STATUS_CODES);
arguments:
- Hello
environment:
NAME: js
- python:
output:
as: '${ $context + { python: . } }'
run:
script:
language: python
code: |
import os
import sys

def main():
arg = sys.argv[1] if len(sys.argv) > 1 else ""

name = os.getenv("NAME", "")

print(f"{arg} from {name}")

if __name__ == "__main__":
main()
arguments:
- Hello
environment:
NAME: python

Shell

Enables the execution of shell commands within a workflow, enabling workflows to interact with the underlying operating system and perform system-level operations, such as file manipulation, environment configuration, or system administration tasks.

Properties

NameTypeRequiredDescription
commandstringyesThe shell command to run
argumentsstring[]noA list of the arguments, if any, to the shell command as argv
environmentmapnoA key/value mapping of the environment variables, if any, to use when running the configured process

Examples

document:
dsl: 1.0.0
namespace: zigflow
name: example
version: 0.0.1
do:
- runShell:
output:
as: '${ $context + { shell: . } }'
run:
shell:
command: ls
arguments:
- -la
- /

Workflow

Enables the invocation and execution of child workflows from a parent workflow, facilitating modularization, reusability, and abstraction of complex logic or business processes by encapsulating them into standalone workflow units.

Properties

NameTypeRequiredDescription
namestringyesThe name of the workflow to run
namespacestringyesThis is not used and only exists to maintain compatability with the Serverless Workflow schema
versionstringyesThis is not used and only exists to maintain compatability with the Serverless Workflow schema
inputanynoThe data, if any, to pass as input to the workflow to execute. The value should be validated against the target workflow's input schema, if specified

Example

document:
dsl: 1.0.0
namespace: zigflow
name: example
version: 0.0.1
timeout:
after:
minutes: 1
do:
- parentWorkflow:
do:
- wait:
wait:
seconds: 5
- callChildWorkflow1:
run:
workflow:
name: child-workflow1
namespace: default
version: 0.0.0
- wait:
wait:
seconds: 5
- callChildWorkflow2:
run:
workflow:
name: child-workflow2
namespace: default
version: 0.0.0
- child-workflow1:
do:
- wait:
wait:
seconds: 10
- child-workflow2:
do:
- wait:
wait:
seconds: 3