Process Process

yaml
type: "io.kestra.plugin.core.runner.Process"

Task runner that executes a task as a subprocess on the Kestra host.

To access the task's working directory, use the {{ workingDir }} Pebble expression or the WORKING_DIR environment variable. Input files and namespace files will be available in this directory.

To generate output files you can either use the outputFiles task's property and create a file with the same name in the task's working directory, or create any file in the output directory which can be accessed by the {{ outputDir }} Pebble expression or the OUTPUT_DIR environment variables.

Note that:

  • This task runner is independent of any Operating System. You can use it equally on Linux, Mac or Windows without any additional configuration.
  • When the Kestra Worker running this task is shut down, the process will be interrupted and re-created as soon as the worker is restarted.

Examples

Execute a Shell command.

yaml
id: new-shell
namespace: company.team

tasks:
  - id: shell
    type: io.kestra.plugin.scripts.shell.Commands
    taskRunner:
      type: io.kestra.plugin.core.runner.Process
    commands:
    - echo "Hello World"

Install custom Python packages before executing a Python script. Note how we use the --break-system-packages flag to avoid conflicts with the system packages. Make sure to use this flag if you see errors similar to error: externally-managed-environment.

yaml
id: before_commands_example
namespace: company.team

inputs:
  - id: url
    type: URI
    defaults: https://jsonplaceholder.typicode.com/todos/1

tasks:
  - id: transform
    type: io.kestra.plugin.scripts.python.Script
    taskRunner:
      type: io.kestra.plugin.core.runner.Process
    beforeCommands:
      - pip install kestra requests --break-system-packages
    script: |
      import requests
      from kestra import Kestra

      url = "{{ inputs.url }}"

      response = requests.get(url)
      print('Status Code:', response.status_code)
      Kestra.outputs(response.json())

Pass input files to the task, execute a Shell command, then retrieve output files.

yaml
id: new-shell-with-file
namespace: company.team

inputs:
  - id: file
    type: FILE

tasks:
  - id: shell
    type: io.kestra.plugin.scripts.shell.Commands
    inputFiles:
      data.txt: "{{inputs.file}}"
    outputFiles:
      - out.txt
    taskRunner:
      type: io.kestra.plugin.core.runner.Process
    commands:
    - cp {{workingDir}}/data.txt {{workingDir}}/out.txt

Properties

Outputs

Definitions

Was this page helpful?