For each of the supported languages (a.o. Python, R, Node.js, Shell), Kestra provides two types of tasks: Script and Commands.

  1. The Script tasks — typically written inline in the YAML flow configuration. They are best suited for short scripts and they make it easy to pass data from flow inputs and other tasks to your custom scripts.
  2. The Commands tasks — best suited for more complex and longer scripts, typically integrated into kestra as namespace files.

The following table gives an overview of all script tasks and their configuration.

LanguageDefault imagebeforeCommands exampleScript exampleCommands example
Pythonpythonpip install requests kestraprint("Hello World!")python hello.py
Rr-baseRscript -e "install.packages('dplyr')"print("Hello World!")Rscript hello.R
Juliajuliajulia -e 'using Pkg; Pkg.add("CSV")'println("Hello World!")julia hello.jl
Rubyrubygem install httpartyputs "Hello World!"ruby hello.rb
Node.jsnodenpm install json2csvconsole.log('Hello World!');node hello.js
Shellubuntuapt-get install curlecho "Hello World!"./hello.bash
PowershellpowershellInstall-Module -Name ImportExcelWrite-Output "Hello World!".\hello.ps1

Full class names:

Check available blueprints to get started with those tasks.

When to use Script over Commands?

The Script pattern has several advantages:

  • Simplicity: the script code is stored and versioned using Kestra's revision history along with your orchestration logic.
  • Easier integration with the templating engine: when the entire workflow is defined in one configuration file, it can be easier to access flow inputs, variable definitions, pass outputs to downstream tasks, etc.

However, the Script tasks also have some disadvantages as compared to the Commands tasks:

  • Readability: adding scripts into a YAML configuration file makes the scripts less readable, especially if they get long. Inline scripts also lack the syntax highlighting and testability that you would get when leveraging our embedded Code Editor instead.
  • Complex use cases: if your business logic comprises multiple files importing classes and functions from other modules, you will need to use the Commands tasks instead.

Overall, we recommend using Commands tasks for advanced production workloads. However, the Script tasks offer a great alternative for simple use cases.

Was this page helpful?