Pipelines
Use Pipelines to orchestrate multiple steps in sequence
A Pipeline in Sling allows you to execute multiple steps in sequence. Each step can be a different type of operation, enabling you to create complex workflows by chaining together various actions like running replications, executing queries, making HTTP requests, and more.
Sling Pipelines integrate seamlessly with the Sling VSCode Extension. The extension provides schema validation, auto-completion, hover documentation, and diagnostics for your pipeline configurations, making it easier to author and debug complex workflows.
Pipeline Configuration
A pipeline is defined in YAML format with a steps key at the root level containing an array of steps. Each step supports the same types and configurations as Hooks.
steps:
- type: log
message: "Starting pipeline execution"
- type: replication
path: path/to/replication.yaml
id: my_replication
- type: query
if: state.my_replication.status == "success"
connection: my_database
query: "UPDATE status SET completed = true"
env:
MY_KEY: VALUEAvailable Step Types
Pipelines support all the same types as Hooks:
Common Step Properties
Each step shares the same common properties as hooks:
type
The type of step (query/ http/ check/ copy / delete/ log / inspect)
Yes
if
Optional condition to determine if the step should execute
No
id
A specific identifier to refer to the step output data
No
On Failure Behaviors
The on_failure property controls what happens when a step fails. It only takes effect if the step errors — on success it has no impact. The following values are supported:
abort (default)
Stops the pipeline immediately and fails the run with the error. This is the behavior when on_failure is not set.
warn
Logs a warning with the error message and continues to the next step. The run is not failed.
quiet
Silently swallows the error (no log output) and continues to the next step. The run is not failed.
break
Stops the current sequence of steps gracefully (without failing the run) and moves on. Useful to stop early without marking the pipeline as failed.
retry
Retries the failed step once. If it fails again, the error is raised.
defer
Only meaningful inside a group: records the error but lets the remaining steps in the group finish, then surfaces the error at the end of the group.
Variables Available
Pipeline steps have access to the runtime state which includes various variables that can be referenced using curly braces {variable}. The available variables include:
runtime_state- Contains all state variables availableenv.*- All variables defined in theenvtimestamp.*- Various timestamp parts informationsteps.*- Output data from previous steps (referenced by theirid)execution.*- Execution-level context, including:execution.cli_args.*- The flags passed on the command line when running the pipeline (see Reading CLI Flags below).
You can view all available variables by using a log step:
Reading CLI Flags
Starting in v1.5.22, the execution.cli_args map exposes the flags passed to sling run, so a pipeline can adapt its behavior based on command-line input. The key is the flag's long name with hyphens replaced by underscores (e.g. --src-conn becomes execution.cli_args.src_conn).
Available Keys
Only flags that are actually passed appear in cli_args (plus the boolean flags, which always appear defaulted to 0). The valid keys are:
replication, pipeline, directory, streams, select, primary_key, update_key, mode, limit, offset, range, where, src_conn, src_stream, src_options, tgt_conn, tgt_object, tgt_options, columns, transforms, env, cdc_options, debug, trace, stdout, examples
The comma-separated flags streams, primary_key and select are always arrays, even when a single value is passed — index them to read individual entries (e.g. execution.cli_args.streams[0]).
Missing Keys
If a flag was not passed, its key is absent from cli_args. Referencing a missing key directly in a check/if expression raises an error (object has no member "..."), so use jmespath to read a possibly-missing key safely — it returns empty instead of erroring:
In a log message (or any rendered template), a missing key simply renders as the un-substituted {execution.cli_args.where} literal rather than erroring.
Example Pipeline
Here's a complete example that demonstrates various pipeline capabilities:
Best Practices
Error Handling: Use appropriate
on_failurebehaviors for each stepValidation: Include check steps to validate critical conditions
Logging: Add log steps for better observability
Modularity: Break down complex operations into multiple steps
Conditions: Use
ifconditions to control step executionVariables: Leverage environment variables and runtime state for dynamic configuration
Identifiers: Use meaningful
ids for steps when you need to reference their output later
Running a Pipeline
You can run a pipeline using the Sling CLI:
Last updated
Was this helpful?