New to Kestra?
Use blueprints to kickstart your first workflows.
Use the Kestra runIf attribute to conditionally execute tasks. Build dynamic workflows that skip or run steps based on runtime conditions.
id: runif-task-attribute
namespace: company.team
triggers:
- id: schedule
type: io.kestra.plugin.core.trigger.Schedule
cron: 0 10 * * *
inputs:
run_everything: true
inputs:
- id: run_everything
type: BOOL
defaults: true
tasks:
- id: step1
type: io.kestra.plugin.core.log.Log
message: "This will always run"
- id: step2
type: io.kestra.plugin.core.log.Log
runIf: "{{ inputs.run_everything }}"
message: "This will only run if set to true"
Conditionally execute individual tasks at runtime using the runIf attribute in Kestra. This flow shows how to skip or run a step based on a boolean input, so you can build one workflow that runs end to end or only selected parts depending on how it is triggered. It is the lightweight alternative to wrapping a single task inside an io.kestra.plugin.core.flow.If block, keeping declarative YAML flat and readable while still giving you full conditional control over execution.
The flow declares a single run_everything input of type BOOL that defaults to true. It then defines two io.kestra.plugin.core.log.Log tasks:
step1 always runs and logs a confirmation message.step2 carries runIf: "{{ inputs.run_everything }}", so it only executes when the input evaluates to true. When the condition is false, Kestra marks the task as skipped rather than failed.A io.kestra.plugin.core.trigger.Schedule trigger fires every day at 0 10 * * * and passes run_everything: true, so scheduled runs always execute every task. Manual runs can flip the input to false to skip the conditional step.
If block.If wrappers around a single conditional task.Kestra makes conditional logic declarative: runIf is a property on the task itself, evaluated against runtime inputs, trigger payloads, or upstream outputs. You get event and schedule triggers, automatic retries, full execution lineage, and a visual topology, all from YAML. A plain scheduler or cron job cannot express per-task conditions, surface a skipped state, or branch a single definition between full and partial runs without custom scripting. Kestra handles that natively.
This flow uses no secrets.
run_everything set to true and confirm both tasks run.run_everything set to false and confirm step2 is skipped.Schedule trigger enabled to run the full flow daily at 10:00.Log tasks for real work such as database writes, API calls, or file processing.runIf from upstream task outputs or trigger variables instead of a static input.runIf conditions to assemble feature-flag style pipelines.runIf alongside io.kestra.plugin.core.flow.If when you need to gate multiple tasks at once.