Return icon
Script icon
Docker icon
Log icon
Commands icon
Process icon

Pass data between Python script tasks and Shell tasks using Outputs

Pass data between Kestra tasks using outputs and variables. Build data-driven workflows where each task consumes and produces structured values and files.

Categories
Core

Learn how to pass data between tasks in Kestra using outputs, the mechanism that lets one task hand off values and files to downstream tasks. This blueprint solves a common orchestration problem: how do you chain a Python script, a Shell command, and core tasks so that each step can consume what the previous step produced, without writing to a shared filesystem or hardcoding values? It demonstrates the three output patterns you need most: a simple returned value, a structured map of variables, and a passed file.

How it works

The flow runs four tasks in sequence:

  • pass_output uses io.kestra.plugin.core.debug.Return to emit a value (hello) that becomes available under the value key.
  • py_outputs uses io.kestra.plugin.scripts.python.Script running on the io.kestra.plugin.scripts.runner.docker.Docker task runner. It calls Kestra.outputs() from the kestra Python package to publish a key/value map, and writes myoutput.json declared in outputFiles.
  • take_inputs uses io.kestra.plugin.core.log.Log to read both upstream results with {{ outputs.pass_output.value }} and {{ outputs.py_outputs.vars.mykey }}.
  • check_output_file uses io.kestra.plugin.scripts.shell.Commands on the io.kestra.plugin.core.runner.Process runner to cat the passed file via {{ outputs.py_outputs.outputFiles['myoutput.json'] }}.

What you get

  • A working reference for the three output types: returned values, the script vars map, and outputFiles.
  • The exact expression syntax to reference upstream outputs ({{ outputs.task_name.vars.key_name }}).
  • A pattern that works across language runtimes (Python, Shell) and core tasks.

Who it's for

  • Data engineers chaining extract, transform, and load steps.
  • Platform teams standardizing how scripts exchange state.
  • Anyone new to Kestra learning the outputs model.

Why orchestrate this with Kestra

A standalone script or cron job has no shared, typed way to hand data between steps: you end up parsing stdout or writing brittle temp files. Kestra makes outputs first-class. Values and files are captured automatically, persisted in internal storage, and addressable from any downstream task with declarative YAML. You also get event triggers, automatic retries, and full execution lineage so you can inspect exactly what each task produced on the Outputs tab. This is the gap a plain scheduler cannot fill: it can run scripts, but it cannot pass and track structured data between them.

Prerequisites

  • A running Kestra instance.
  • Docker available for the Python script task runner.

Secrets

This flow references no secrets.

Quick start

  1. Add the flow to your namespace.
  2. Execute it from the UI.
  3. Open the Outputs tab on the Execution page to see value, vars, and outputFiles.
  4. Read the check_output_file logs to confirm the JSON file was passed through.

How to extend

  • Replace the Python script with your own logic that calls Kestra.outputs().
  • Feed outputFiles into a downstream upload, database load, or notification task.
  • Add inputs and reference them alongside outputs to build fully parameterized pipelines.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.