type: "io.kestra.plugin.scripts.shell.Commands"
Execute one or more Shell commands.
Examples
Execute ETL in Rust in a Docker container and output CSV files generated as a result of the script.
id: rust_flow
namespace: company.team
tasks:
- id: rust
type: io.kestra.plugin.scripts.shell.Commands
commands:
- etl
containerImage: ghcr.io/kestra-io/rust:latest
outputFiles:
- "*.csv"
Execute a single Shell command.
id: shell_single_command
namespace: company.team
tasks:
- id: command
type: io.kestra.plugin.scripts.shell.Commands
commands:
- 'echo "The current execution is: {{ execution.id }}"'
Include only specific namespace files.
id: include_files
namespace: company.team
tasks:
- id: command
type: io.kestra.plugin.scripts.shell.Commands
description: "Only the included `namespaceFiles` get listed"
namespaceFiles:
enabled: true
include:
- test1.txt
- test2.yaml
commands:
- ls
Exclude specific namespace files.
id: exclude_files
namespace: company.team
tasks:
- id: command
type: io.kestra.plugin.scripts.shell.Commands
description: "All `namespaceFiles` except those that are excluded will be injected into the task's working directory"
namespaceFiles:
enabled: true
exclude:
- test1.txt
- test2.yaml
commands:
- ls
Execute Shell commands that generate files accessible by other tasks and available for download in the UI's Output tab.
id: shell_generate_files
namespace: company.team
tasks:
- id: commands
type: io.kestra.plugin.scripts.shell.Commands
outputFiles:
- first.txt
- second.txt
commands:
- echo "1" >> first.txt
- echo "2" >> second.txt
Execute a Shell command using an input file generated in a previous task.
id: use_input_file
namespace: company.team
tasks:
- id: http_download
type: io.kestra.plugin.core.http.Download
uri: https://huggingface.co/datasets/kestra/datasets/raw/main/csv/products.csv
- id: commands
type: io.kestra.plugin.scripts.shell.Commands
commands:
- cat {{ outputs.http_download.uri }}
Run a PHP Docker container and execute a command.
id: run_php_code
namespace: company.team
tasks:
- id: commands
type: io.kestra.plugin.scripts.shell.Commands
taskRunner:
type: io.kestra.plugin.scripts.runner.docker.Docker
containerImage: php
commands:
- php -r 'print(phpversion());'
Create output variables from a standard output.
id: create_output_variables
namespace: company.team
tasks:
- id: commands
type: io.kestra.plugin.scripts.shell.Commands
commands:
- echo '::{"outputs":{"test":"value","int":2,"bool":true,"float":3.65}}::'
Send a counter metric from a standard output.
id: create_counter_metric
namespace: company.team
tasks:
- id: commands
type: io.kestra.plugin.scripts.shell.Commands
commands:
- echo '::{"metrics":[{"name":"count","type":"counter","value":1,"tags":{"tag1":"i","tag2":"win"}}]}::'
Properties
commands
- Type: array
- SubType: string
- Dynamic: ✔️
- Required: ✔️
- Min items:
1
Shell commands to run.
interpreter
- Type: array
- SubType: string
- Dynamic: ❌
- Required: ✔️
- Default:
[ "/bin/sh", "-c" ]
- Min items:
1
Which interpreter to use.
warningOnStdErr
- Type: boolean
- Dynamic: ❌
- Required: ✔️
- Default:
true
Whether to set the task state to WARNING
when any stdErr
output is detected.
Note that a script error will set the state to
FAILED
regardless.
beforeCommands
- Type: array
- SubType: string
- Dynamic: ✔️
- Required: ❌
A list of commands that will run before the commands
, allowing to set up the environment e.g. pip install -r requirements.txt
.
containerImage
- Type: string
- Dynamic: ✔️
- Required: ❌
- Default:
ubuntu
The task runner container image, only used if the task runner is container-based.
docker
- Type: DockerOptions
- Dynamic: ❌
- Required: ❌
Deprecated - use the 'taskRunner' property instead.
Only used if the
taskRunner
property is not set
env
- Type: object
- SubType: string
- Dynamic: ✔️
- Required: ❌
Additional environment variables for the current process.
failFast
- Type: boolean
- Dynamic: ❌
- Required: ❌
- Default:
true
Fail the task on the first command with a non-zero status.
If set to
false
all commands will be executed one after the other. The final state of task execution is determined by the last command. Note that this property maybe be ignored if a non compatible interpreter is specified. You can also disable it if your interpreter does not support theset -e
option.
inputFiles
- Type:
- object
- string
- Dynamic: ✔️
- Required: ❌
The files to create on the local filesystem. It can be a map or a JSON object.
namespaceFiles
- Type: NamespaceFiles
- Dynamic: ❌
- Required: ❌
Inject namespace files.
Inject namespace files to this task. When enabled, it will, by default, load all namespace files into the working directory. However, you can use the
include
orexclude
properties to limit which namespace files will be injected.
outputDirectory
- Type: boolean
- Dynamic: ❌
- Required: ❌
- Default:
false
Whether to setup the output directory mechanism.
Required to use the expression. Note that it could increase the starting time. Deprecated, use the
outputFiles
property instead.
outputFiles
- Type: array
- SubType: string
- Dynamic: ✔️
- Required: ❌
The files from the local filesystem to send to Kestra's internal storage.
Must be a list of glob) expressions relative to the current working directory, some examples:
my-dir/
,my-dir/*/
ormy-dir/my-file.txt
.
runner
- Type: string
- Dynamic: ❌
- Required: ❌
- Possible Values:
PROCESS
DOCKER
Deprecated - use the 'taskRunner' property instead.
Only used if the
taskRunner
property is not set
targetOS
- Type: string
- Dynamic: ❌
- Required: ❌
- Default:
AUTO
- Possible Values:
LINUX
WINDOWS
AUTO
The target operating system where the script will run.
taskRunner
- Type: TaskRunner
- Dynamic: ❌
- Required: ❌
- Default:
{ "type": "io.kestra.plugin.scripts.runner.docker.Docker" }
The task runner to use.
Task runners are provided by plugins, each have their own properties.
Outputs
exitCode
- Type: integer
- Required: ✔️
- Default:
0
outputFiles
- Type: object
- SubType: string
- Required: ❌
vars
- Type: object
- Required: ❌
Definitions
io.kestra.core.models.tasks.NamespaceFiles
enabled
- Type: boolean
- Dynamic: ❌
- Required: ❌
- Default:
true
exclude
- Type: array
- SubType: string
- Dynamic: ❌
- Required: ❌
include
- Type: array
- SubType: string
- Dynamic: ❌
- Required: ❌
io.kestra.plugin.scripts.runner.docker.Cpu
cpus
- Type: integer
- Dynamic: ❌
- Required: ❌
io.kestra.core.models.tasks.runners.TaskRunner
type
- Type: string
- Dynamic: ❌
- Required: ✔️
- Validation RegExp:
\p{javaJavaIdentifierStart}\p{javaJavaIdentifierPart}*(\.\p{javaJavaIdentifierStart}\p{javaJavaIdentifierPart}*)*
- Min length:
1
io.kestra.plugin.scripts.runner.docker.Memory
kernelMemory
- Type: string
- Dynamic: ✔️
- Required: ❌
memory
- Type: string
- Dynamic: ✔️
- Required: ❌
memoryReservation
- Type: string
- Dynamic: ✔️
- Required: ❌
memorySwap
- Type: string
- Dynamic: ✔️
- Required: ❌
memorySwappiness
- Type: string
- Dynamic: ✔️
- Required: ❌
oomKillDisable
- Type: boolean
- Dynamic: ❌
- Required: ❌
io.kestra.plugin.scripts.exec.scripts.models.DockerOptions
image
- Type: string
- Dynamic: ✔️
- Required: ✔️
- Min length:
1
config
- Type:
- string
- object
- Dynamic: ✔️
- Required: ❌
- Type:
cpu
- Type: Cpu
- Dynamic: ❌
- Required: ❌
credentials
- Type: Credentials
- Dynamic: ✔️
- Required: ❌
deviceRequests
- Type: array
- SubType: DeviceRequest
- Dynamic: ❌
- Required: ❌
entryPoint
- Type: array
- SubType: string
- Dynamic: ✔️
- Required: ❌
extraHosts
- Type: array
- SubType: string
- Dynamic: ✔️
- Required: ❌
host
- Type: string
- Dynamic: ✔️
- Required: ❌
memory
- Type: Memory
- Dynamic: ❌
- Required: ❌
networkMode
- Type: string
- Dynamic: ✔️
- Required: ❌
pullPolicy
- Type: string
- Dynamic: ❌
- Required: ❌
- Default:
ALWAYS
- Possible Values:
IF_NOT_PRESENT
ALWAYS
NEVER
shmSize
- Type: string
- Dynamic: ✔️
- Required: ❌
user
- Type: string
- Dynamic: ✔️
- Required: ❌
volumes
- Type: array
- SubType: string
- Dynamic: ✔️
- Required: ❌
io.kestra.plugin.scripts.runner.docker.Credentials
auth
- Type: string
- Dynamic: ✔️
- Required: ❌
identityToken
- Type: string
- Dynamic: ✔️
- Required: ❌
password
- Type: string
- Dynamic: ✔️
- Required: ❌
registry
- Type: string
- Dynamic: ✔️
- Required: ❌
registryToken
- Type: string
- Dynamic: ✔️
- Required: ❌
username
- Type: string
- Dynamic: ✔️
- Required: ❌
io.kestra.plugin.scripts.runner.docker.DeviceRequest
capabilities
- Type: array
- SubType: array
- Dynamic: ❌
- Required: ❌
count
- Type: integer
- Dynamic: ❌
- Required: ❌
deviceIds
- Type: array
- SubType: string
- Dynamic: ✔️
- Required: ❌
driver
- Type: string
- Dynamic: ✔️
- Required: ❌
options
- Type: object
- SubType: string
- Dynamic: ❌
- Required: ❌