Workflow variables catalog¶
Auto-generated from util/variables via GenerateMarkdown(). 83 variables registered.
Skipped and omitted nodes: when a step or task is skipped (its when evaluates false) or omitted (its dependencies never ran), it produces no real outputs. Its outputs.parameters.<name>, outputs.result and outputs.artifacts.<name> variables are still populated with empty placeholder values, so downstream references resolve to empty rather than leaving the workflow stuck on an unresolvable variable.
A runnable variables-showcase.yaml workflow that exercises these variables is embedded at the end of this page.
1. Alphabetical index¶
| Key | Kind | Type | Availability | Description |
|---|---|---|---|---|
cronworkflow.annotations |
cron-workflow | map | cron-eval | CronWorkflow annotations as a map; supports nested key access (cronworkflow.annotations.foo) |
cronworkflow.annotations.json |
cron-workflow | json | cron-eval | CronWorkflow annotations as a JSON object |
cronworkflow.failed |
cron-workflow | int | cron-eval | Count of failed child Workflows |
cronworkflow.labels |
cron-workflow | map | cron-eval | CronWorkflow labels as a map; supports nested key access (cronworkflow.labels.foo) |
cronworkflow.labels.json |
cron-workflow | json | cron-eval | CronWorkflow labels as a JSON object |
cronworkflow.lastScheduledTime |
cron-workflow | *time.Time | cron-eval | Time the cron last triggered, or nil before the first run |
cronworkflow.name |
cron-workflow | string | cron-eval | CronWorkflow object name |
cronworkflow.namespace |
cron-workflow | string | cron-eval | CronWorkflow namespace |
cronworkflow.succeeded |
cron-workflow | int | cron-eval | Count of succeeded child Workflows |
duration |
metric | string | metric-emission | Current node's elapsed duration in seconds |
exitCode |
metric | string | metric-emission | Current node's container exit code |
inputs.artifacts.<name> |
input | wfv1.Artifact | during-execute | Input artifact object (for fromExpression use) |
inputs.artifacts.<name>.path |
input | string | during-execute | Mount path of the input artifact inside the pod |
inputs.parameters |
input | json | during-execute | All input parameters as a JSON array |
inputs.parameters.<name> |
input | string | during-execute | Resolved input parameter value |
item |
item | string or json | inside-loop | Current loop iteration value (withItems/withParam). JSON for map/list items. |
item.<key> |
item | string | inside-loop | Accessor into a map-typed loop iteration value |
lastRetry.duration |
retry | string | inside-retry | Duration of the previous attempt in seconds |
lastRetry.exitCode |
retry | string | inside-retry | Exit code of the previous attempt (or 0 on first attempt) |
lastRetry.message |
retry | string | inside-retry | Message of the previous attempt |
lastRetry.status |
retry | string | inside-retry | Phase of the previous attempt (or empty on first) |
node.name |
node-ctx | string | pre-dispatch, during-execute | Full node name |
outputs.artifacts.<name>.path |
output | string | during-execute | Declared output artifact path for the current template (pod side) |
outputs.parameters.<name> |
metric | string | metric-emission | Current node's named output parameter value (metric scope only) |
outputs.parameters.<name>.path |
output | string | during-execute | Declared output parameter path for the current template (pod side) |
outputs.result |
metric | string | metric-emission | Current node's captured stdout (metric scope only) |
pod.name |
node-ctx | string | pre-dispatch, during-execute | Computed pod name for pod-producing templates |
resourcesDuration.<resource> |
metric | string | metric-emission | Current node's resource duration in seconds, keyed by Kubernetes resource name (e.g. cpu, memory) |
retries |
retry | string | inside-retry | 0-based retry attempt index |
status |
metric | string | metric-emission | Current node's phase |
steps.<loopName>.outputs.parameters |
node-ref | json | after-loop | JSON array of per-child output-parameter maps |
steps.<loopName>.outputs.parameters.<p> |
node-ref | json | after-loop | JSON array of values for a named parameter across all children |
steps.<loopName>.outputs.result |
node-ref | json | after-loop | JSON array of child results (withItems/withParam) |
steps.<name>.exitCode |
node-ref | string | after-node-complete | Container exit code |
steps.<name>.finishedAt |
node-ref | string | after-node-complete | RFC3339 finish time |
steps.<name>.hostNodeName |
node-ref | string | after-pod-start | Underlying k8s node name |
steps.<name>.id |
node-ref | string | after-node-init | Node ID |
steps.<name>.ip |
node-ref | string | after-pod-start | Pod IP |
steps.<name>.outputs.artifacts.<a> |
node-ref | wfv1.Artifact | after-node-succeeded | Named output artifact of the referenced node |
steps.<name>.outputs.parameters.<p> |
node-ref | string | after-node-succeeded | Named output parameter of the referenced node |
steps.<name>.outputs.result |
node-ref | string | after-node-succeeded | Captured stdout (non-loop nodes) |
steps.<name>.startedAt |
node-ref | string | after-node-init | RFC3339 start time (set at controller node-init, before pod creation; populated for all node types) |
steps.<name>.status |
node-ref | string | after-node-init | Node phase |
steps.name |
node-ctx | string | pre-dispatch, during-execute | Name of the current step (inside a Steps template body) |
tasks.<loopName>.outputs.parameters |
node-ref | json | after-loop | JSON array of per-child output-parameter maps |
tasks.<loopName>.outputs.parameters.<p> |
node-ref | json | after-loop | JSON array of values for a named parameter across all children |
tasks.<loopName>.outputs.result |
node-ref | json | after-loop | JSON array of child results (withItems/withParam) |
tasks.<name>.exitCode |
node-ref | string | after-node-complete | Container exit code |
tasks.<name>.finishedAt |
node-ref | string | after-node-complete | RFC3339 finish time |
tasks.<name>.hostNodeName |
node-ref | string | after-pod-start | Underlying k8s node name |
tasks.<name>.id |
node-ref | string | after-node-init | Node ID |
tasks.<name>.ip |
node-ref | string | after-pod-start | Pod IP |
tasks.<name>.outputs.artifacts.<a> |
node-ref | wfv1.Artifact | after-node-succeeded | Named output artifact of the referenced node |
tasks.<name>.outputs.parameters.<p> |
node-ref | string | after-node-succeeded | Named output parameter of the referenced node |
tasks.<name>.outputs.result |
node-ref | string | after-node-succeeded | Captured stdout (non-loop nodes) |
tasks.<name>.startedAt |
node-ref | string | after-node-init | RFC3339 start time (set at controller node-init, before pod creation; populated for all node types) |
tasks.<name>.status |
node-ref | string | after-node-init | Node phase |
tasks.name |
node-ctx | string | pre-dispatch, during-execute | Name of the current task (inside a DAG template body) |
workflow.annotations |
global | json | workflow-start, pre-dispatch, during-execute, exit-handler | All workflow annotations as a JSON object (deprecated — use workflow.annotations.json) |
workflow.annotations.<name> |
global | string | workflow-start, pre-dispatch, during-execute, exit-handler | Workflow metadata annotation value |
workflow.annotations.json |
global | json | workflow-start, pre-dispatch, during-execute, exit-handler | All workflow annotations as a JSON object |
workflow.creationTimestamp |
global | string | workflow-start, pre-dispatch, during-execute, exit-handler | RFC3339 creation timestamp |
workflow.creationTimestamp.<fmt> |
global | string | workflow-start, pre-dispatch, during-execute, exit-handler | strftime-formatted workflow creation time; <fmt> is one of the chars in util/strftime |
workflow.creationTimestamp.RFC3339 |
global | string | workflow-start, pre-dispatch, during-execute, exit-handler | Workflow creation time as RFC3339 |
workflow.creationTimestamp.s |
global | string | workflow-start, pre-dispatch, during-execute, exit-handler | Workflow creation time as Unix seconds |
workflow.duration |
runtime | string | pre-dispatch, during-execute, exit-handler | Elapsed seconds as float string; final at exit handler |
workflow.failures |
runtime | json | exit-handler | Failed-node descriptors. Wire format: a strconv.Quote-wrapped JSON string — consumers must JSON-decode twice. When no nodes have failed, the value is the literal 6-character string "null" (with quotes), not an empty array. |
workflow.labels |
global | json | workflow-start, pre-dispatch, during-execute, exit-handler | All workflow labels as a JSON object (deprecated — use workflow.labels.json) |
workflow.labels.<name> |
global | string | workflow-start, pre-dispatch, during-execute, exit-handler | Workflow metadata label value |
workflow.labels.json |
global | json | workflow-start, pre-dispatch, during-execute, exit-handler | All workflow labels as a JSON object |
workflow.mainEntrypoint |
global | string | workflow-start, pre-dispatch, during-execute, exit-handler | spec.entrypoint |
workflow.name |
global | string | workflow-start, pre-dispatch, during-execute, exit-handler | Workflow object name |
workflow.namespace |
global | string | workflow-start, pre-dispatch, during-execute, exit-handler | Workflow namespace |
workflow.outputs.artifacts.<name> |
node-ref | wfv1.Artifact | during-execute, exit-handler | Global output artifact (lifted via outputs.artifacts[*].globalName) |
workflow.outputs.parameters.<name> |
node-ref | string | during-execute, exit-handler | Global output parameter (lifted via outputs.parameters[*].globalName) |
workflow.parameters |
global | json | workflow-start, pre-dispatch, during-execute, exit-handler | All workflow parameters as a JSON array |
workflow.parameters.<name> |
global | string | workflow-start, pre-dispatch, during-execute, exit-handler | Value from spec.arguments.parameters, ConfigMap-resolved if ValueFrom is set |
workflow.parameters.json |
global | json | workflow-start, pre-dispatch, during-execute, exit-handler | All workflow parameters as a JSON array (alias for workflow.parameters) |
workflow.priority |
global | string | workflow-start, pre-dispatch, during-execute, exit-handler | Workflow priority. Conditional — resolves only when spec.priority is set; otherwise both lint and runtime treat the reference as undefined (no empty/zero fallback). |
workflow.scheduledTime |
global | string | workflow-start, pre-dispatch, during-execute, exit-handler | Scheduled time for cron-triggered workflows. Conditional — resolves only when annotation workflows.argoproj.io/scheduled-time is present (set automatically by the cron controller). Lint passes via prefix exemption but on a non-cron Workflow the runtime leaves the literal {{workflow.scheduledTime}} in resolved values rather than substituting empty. |
workflow.serviceAccountName |
global | string | workflow-start, pre-dispatch, during-execute, exit-handler | Effective service account name |
workflow.status |
runtime | string | pre-dispatch, during-execute, exit-handler | Current workflow phase; final value only at exit handler |
workflow.uid |
global | string | workflow-start, pre-dispatch, during-execute, exit-handler | Workflow UID |
2. Grouped by Kind¶
Global¶
| Key | Type | Availability | Description |
|---|---|---|---|
workflow.annotations |
json | workflow-start, pre-dispatch, during-execute, exit-handler | All workflow annotations as a JSON object (deprecated — use workflow.annotations.json) |
workflow.annotations.<name> |
string | workflow-start, pre-dispatch, during-execute, exit-handler | Workflow metadata annotation value |
workflow.annotations.json |
json | workflow-start, pre-dispatch, during-execute, exit-handler | All workflow annotations as a JSON object |
workflow.creationTimestamp |
string | workflow-start, pre-dispatch, during-execute, exit-handler | RFC3339 creation timestamp |
workflow.creationTimestamp.<fmt> |
string | workflow-start, pre-dispatch, during-execute, exit-handler | strftime-formatted workflow creation time; <fmt> is one of the chars in util/strftime |
workflow.creationTimestamp.RFC3339 |
string | workflow-start, pre-dispatch, during-execute, exit-handler | Workflow creation time as RFC3339 |
workflow.creationTimestamp.s |
string | workflow-start, pre-dispatch, during-execute, exit-handler | Workflow creation time as Unix seconds |
workflow.labels |
json | workflow-start, pre-dispatch, during-execute, exit-handler | All workflow labels as a JSON object (deprecated — use workflow.labels.json) |
workflow.labels.<name> |
string | workflow-start, pre-dispatch, during-execute, exit-handler | Workflow metadata label value |
workflow.labels.json |
json | workflow-start, pre-dispatch, during-execute, exit-handler | All workflow labels as a JSON object |
workflow.mainEntrypoint |
string | workflow-start, pre-dispatch, during-execute, exit-handler | spec.entrypoint |
workflow.name |
string | workflow-start, pre-dispatch, during-execute, exit-handler | Workflow object name |
workflow.namespace |
string | workflow-start, pre-dispatch, during-execute, exit-handler | Workflow namespace |
workflow.parameters |
json | workflow-start, pre-dispatch, during-execute, exit-handler | All workflow parameters as a JSON array |
workflow.parameters.<name> |
string | workflow-start, pre-dispatch, during-execute, exit-handler | Value from spec.arguments.parameters, ConfigMap-resolved if ValueFrom is set |
workflow.parameters.json |
json | workflow-start, pre-dispatch, during-execute, exit-handler | All workflow parameters as a JSON array (alias for workflow.parameters) |
workflow.priority |
string | workflow-start, pre-dispatch, during-execute, exit-handler | Workflow priority. Conditional — resolves only when spec.priority is set; otherwise both lint and runtime treat the reference as undefined (no empty/zero fallback). |
workflow.scheduledTime |
string | workflow-start, pre-dispatch, during-execute, exit-handler | Scheduled time for cron-triggered workflows. Conditional — resolves only when annotation workflows.argoproj.io/scheduled-time is present (set automatically by the cron controller). Lint passes via prefix exemption but on a non-cron Workflow the runtime leaves the literal {{workflow.scheduledTime}} in resolved values rather than substituting empty. |
workflow.serviceAccountName |
string | workflow-start, pre-dispatch, during-execute, exit-handler | Effective service account name |
workflow.uid |
string | workflow-start, pre-dispatch, during-execute, exit-handler | Workflow UID |
Runtime¶
| Key | Type | Availability | Description |
|---|---|---|---|
workflow.duration |
string | pre-dispatch, during-execute, exit-handler | Elapsed seconds as float string; final at exit handler |
workflow.failures |
json | exit-handler | Failed-node descriptors. Wire format: a strconv.Quote-wrapped JSON string — consumers must JSON-decode twice. When no nodes have failed, the value is the literal 6-character string "null" (with quotes), not an empty array. |
workflow.status |
string | pre-dispatch, during-execute, exit-handler | Current workflow phase; final value only at exit handler |
Input¶
| Key | Type | Availability | Description |
|---|---|---|---|
inputs.artifacts.<name> |
wfv1.Artifact | during-execute | Input artifact object (for fromExpression use) |
inputs.artifacts.<name>.path |
string | during-execute | Mount path of the input artifact inside the pod |
inputs.parameters |
json | during-execute | All input parameters as a JSON array |
inputs.parameters.<name> |
string | during-execute | Resolved input parameter value |
Output¶
| Key | Type | Availability | Description |
|---|---|---|---|
outputs.artifacts.<name>.path |
string | during-execute | Declared output artifact path for the current template (pod side) |
outputs.parameters.<name>.path |
string | during-execute | Declared output parameter path for the current template (pod side) |
Node-ref¶
| Key | Type | Availability | Description |
|---|---|---|---|
steps.<loopName>.outputs.parameters |
json | after-loop | JSON array of per-child output-parameter maps |
steps.<loopName>.outputs.parameters.<p> |
json | after-loop | JSON array of values for a named parameter across all children |
steps.<loopName>.outputs.result |
json | after-loop | JSON array of child results (withItems/withParam) |
steps.<name>.exitCode |
string | after-node-complete | Container exit code |
steps.<name>.finishedAt |
string | after-node-complete | RFC3339 finish time |
steps.<name>.hostNodeName |
string | after-pod-start | Underlying k8s node name |
steps.<name>.id |
string | after-node-init | Node ID |
steps.<name>.ip |
string | after-pod-start | Pod IP |
steps.<name>.outputs.artifacts.<a> |
wfv1.Artifact | after-node-succeeded | Named output artifact of the referenced node |
steps.<name>.outputs.parameters.<p> |
string | after-node-succeeded | Named output parameter of the referenced node |
steps.<name>.outputs.result |
string | after-node-succeeded | Captured stdout (non-loop nodes) |
steps.<name>.startedAt |
string | after-node-init | RFC3339 start time (set at controller node-init, before pod creation; populated for all node types) |
steps.<name>.status |
string | after-node-init | Node phase |
tasks.<loopName>.outputs.parameters |
json | after-loop | JSON array of per-child output-parameter maps |
tasks.<loopName>.outputs.parameters.<p> |
json | after-loop | JSON array of values for a named parameter across all children |
tasks.<loopName>.outputs.result |
json | after-loop | JSON array of child results (withItems/withParam) |
tasks.<name>.exitCode |
string | after-node-complete | Container exit code |
tasks.<name>.finishedAt |
string | after-node-complete | RFC3339 finish time |
tasks.<name>.hostNodeName |
string | after-pod-start | Underlying k8s node name |
tasks.<name>.id |
string | after-node-init | Node ID |
tasks.<name>.ip |
string | after-pod-start | Pod IP |
tasks.<name>.outputs.artifacts.<a> |
wfv1.Artifact | after-node-succeeded | Named output artifact of the referenced node |
tasks.<name>.outputs.parameters.<p> |
string | after-node-succeeded | Named output parameter of the referenced node |
tasks.<name>.outputs.result |
string | after-node-succeeded | Captured stdout (non-loop nodes) |
tasks.<name>.startedAt |
string | after-node-init | RFC3339 start time (set at controller node-init, before pod creation; populated for all node types) |
tasks.<name>.status |
string | after-node-init | Node phase |
workflow.outputs.artifacts.<name> |
wfv1.Artifact | during-execute, exit-handler | Global output artifact (lifted via outputs.artifacts[*].globalName) |
workflow.outputs.parameters.<name> |
string | during-execute, exit-handler | Global output parameter (lifted via outputs.parameters[*].globalName) |
Item¶
| Key | Type | Availability | Description |
|---|---|---|---|
item |
string or json | inside-loop | Current loop iteration value (withItems/withParam). JSON for map/list items. |
item.<key> |
string | inside-loop | Accessor into a map-typed loop iteration value |
Retry¶
| Key | Type | Availability | Description |
|---|---|---|---|
lastRetry.duration |
string | inside-retry | Duration of the previous attempt in seconds |
lastRetry.exitCode |
string | inside-retry | Exit code of the previous attempt (or 0 on first attempt) |
lastRetry.message |
string | inside-retry | Message of the previous attempt |
lastRetry.status |
string | inside-retry | Phase of the previous attempt (or empty on first) |
retries |
string | inside-retry | 0-based retry attempt index |
Node-ctx¶
| Key | Type | Availability | Description |
|---|---|---|---|
node.name |
string | pre-dispatch, during-execute | Full node name |
pod.name |
string | pre-dispatch, during-execute | Computed pod name for pod-producing templates |
steps.name |
string | pre-dispatch, during-execute | Name of the current step (inside a Steps template body) |
tasks.name |
string | pre-dispatch, during-execute | Name of the current task (inside a DAG template body) |
Metric¶
| Key | Type | Availability | Description |
|---|---|---|---|
duration |
string | metric-emission | Current node's elapsed duration in seconds |
exitCode |
string | metric-emission | Current node's container exit code |
outputs.parameters.<name> |
string | metric-emission | Current node's named output parameter value (metric scope only) |
outputs.result |
string | metric-emission | Current node's captured stdout (metric scope only) |
resourcesDuration.<resource> |
string | metric-emission | Current node's resource duration in seconds, keyed by Kubernetes resource name (e.g. cpu, memory) |
status |
string | metric-emission | Current node's phase |
Cron-workflow¶
| Key | Type | Availability | Description |
|---|---|---|---|
cronworkflow.annotations |
map | cron-eval | CronWorkflow annotations as a map; supports nested key access (cronworkflow.annotations.foo) |
cronworkflow.annotations.json |
json | cron-eval | CronWorkflow annotations as a JSON object |
cronworkflow.failed |
int | cron-eval | Count of failed child Workflows |
cronworkflow.labels |
map | cron-eval | CronWorkflow labels as a map; supports nested key access (cronworkflow.labels.foo) |
cronworkflow.labels.json |
json | cron-eval | CronWorkflow labels as a JSON object |
cronworkflow.lastScheduledTime |
*time.Time | cron-eval | Time the cron last triggered, or nil before the first run |
cronworkflow.name |
string | cron-eval | CronWorkflow object name |
cronworkflow.namespace |
string | cron-eval | CronWorkflow namespace |
cronworkflow.succeeded |
int | cron-eval | Count of succeeded child Workflows |
3. Matrix by TemplateKind¶
Which variables are in scope for each template type. • = in scope, blank = not in scope.
| Key | any | container | container-set | script | resource | steps | dag | data | suspend | http | plugin | exit-handler | cron-workflow |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cronworkflow.annotations |
• | ||||||||||||
cronworkflow.annotations.json |
• | ||||||||||||
cronworkflow.failed |
• | ||||||||||||
cronworkflow.labels |
• | ||||||||||||
cronworkflow.labels.json |
• | ||||||||||||
cronworkflow.lastScheduledTime |
• | ||||||||||||
cronworkflow.name |
• | ||||||||||||
cronworkflow.namespace |
• | ||||||||||||
cronworkflow.succeeded |
• | ||||||||||||
duration |
• | • | • | • | • | • | • | • | • | • | • | • | |
exitCode |
• | • | • | • | • | • | • | • | • | • | • | • | |
inputs.artifacts.<name> |
• | • | • | • | • | • | • | • | • | • | • | • | |
inputs.artifacts.<name>.path |
• | • | • | • | • | • | |||||||
inputs.parameters |
• | • | • | • | • | • | • | • | • | • | • | • | |
inputs.parameters.<name> |
• | • | • | • | • | • | • | • | • | • | • | • | |
item |
• | • | • | • | • | • | • | • | • | • | • | ||
item.<key> |
• | • | • | • | • | • | • | • | • | • | • | ||
lastRetry.duration |
• | • | • | • | • | • | • | • | • | ||||
lastRetry.exitCode |
• | • | • | • | • | • | • | • | • | ||||
lastRetry.message |
• | • | • | • | • | • | • | • | • | ||||
lastRetry.status |
• | • | • | • | • | • | • | • | • | ||||
node.name |
• | • | • | • | • | • | • | • | • | • | • | • | |
outputs.artifacts.<name>.path |
• | • | • | • | • | • | |||||||
outputs.parameters.<name> |
• | • | • | • | • | • | • | • | • | • | • | • | |
outputs.parameters.<name>.path |
• | • | • | • | • | • | |||||||
outputs.result |
• | • | • | • | • | • | • | • | • | • | • | • | |
pod.name |
• | • | • | • | • | • | |||||||
resourcesDuration.<resource> |
• | • | • | • | • | • | • | • | • | • | • | • | |
retries |
• | • | • | • | • | • | • | • | • | ||||
status |
• | • | • | • | • | • | • | • | • | • | • | • | |
steps.<loopName>.outputs.parameters |
• | • | |||||||||||
steps.<loopName>.outputs.parameters.<p> |
• | • | |||||||||||
steps.<loopName>.outputs.result |
• | • | |||||||||||
steps.<name>.exitCode |
• | • | |||||||||||
steps.<name>.finishedAt |
• | • | |||||||||||
steps.<name>.hostNodeName |
• | • | |||||||||||
steps.<name>.id |
• | • | |||||||||||
steps.<name>.ip |
• | • | |||||||||||
steps.<name>.outputs.artifacts.<a> |
• | • | |||||||||||
steps.<name>.outputs.parameters.<p> |
• | • | |||||||||||
steps.<name>.outputs.result |
• | • | |||||||||||
steps.<name>.startedAt |
• | • | |||||||||||
steps.<name>.status |
• | • | |||||||||||
steps.name |
• | ||||||||||||
tasks.<loopName>.outputs.parameters |
• | • | |||||||||||
tasks.<loopName>.outputs.parameters.<p> |
• | • | |||||||||||
tasks.<loopName>.outputs.result |
• | • | |||||||||||
tasks.<name>.exitCode |
• | • | |||||||||||
tasks.<name>.finishedAt |
• | • | |||||||||||
tasks.<name>.hostNodeName |
• | • | |||||||||||
tasks.<name>.id |
• | • | |||||||||||
tasks.<name>.ip |
• | • | |||||||||||
tasks.<name>.outputs.artifacts.<a> |
• | • | |||||||||||
tasks.<name>.outputs.parameters.<p> |
• | • | |||||||||||
tasks.<name>.outputs.result |
• | • | |||||||||||
tasks.<name>.startedAt |
• | • | |||||||||||
tasks.<name>.status |
• | • | |||||||||||
tasks.name |
• | ||||||||||||
workflow.annotations |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.annotations.<name> |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.annotations.json |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.creationTimestamp |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.creationTimestamp.<fmt> |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.creationTimestamp.RFC3339 |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.creationTimestamp.s |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.duration |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.failures |
• | • | |||||||||||
workflow.labels |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.labels.<name> |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.labels.json |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.mainEntrypoint |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.name |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.namespace |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.outputs.artifacts.<name> |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.outputs.parameters.<name> |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.parameters |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.parameters.<name> |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.parameters.json |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.priority |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.scheduledTime |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.serviceAccountName |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.status |
• | • | • | • | • | • | • | • | • | • | • | • | |
workflow.uid |
• | • | • | • | • | • | • | • | • | • | • | • |
4. Grouped by LifecyclePhase¶
| Phase | Meaning |
|---|---|
| workflow-start | Globals populated once, up front, before any template runs. |
| pre-dispatch | Immediately before a template's pod is created; pod.name / node.name / steps.name / tasks.name are set. |
| during-execute | Inside a template body; inputs.* are bound. |
| inside-loop | Inside a withItems/withParam expansion; item, item.<key> are bound. |
| inside-retry | Inside a retryStrategy template; retries.* are bound. |
| after-node-init | A referenced node has been initialized by the controller (id, status, startedAt are populated — startedAt is set at node-init time, before any pod is created, for all node types including non-pod ones like Suspend / HTTP / Plugin / Steps / DAG). |
| after-pod-start | The referenced node's pod has started; ip, hostNodeName are populated (k8s-supplied; meaningless for non-pod node types). |
| after-node-complete | The referenced node has finished (any terminal phase); finishedAt, exitCode are populated. |
| after-node-succeeded | The referenced node has finished with Succeeded; outputs.result, outputs.parameters., outputs.artifacts. are populated. |
| after-loop | Every child of a withItems/withParam group has completed; aggregated outputs appear. |
| exit-handler | The onExit template runs. workflow.{status,failures,duration} are final. Any earlier-phase variable is also visible here (scope accumulates). |
| metric-emission | Inside a Prometheus metric expression. Adds duration, status, exitCode, resourcesDuration.<resource>, and the current node's bare outputs.result / outputs.parameters.<name>. |
| cron-eval | Evaluating a CronWorkflow spec.when or spec.stopStrategy.expression. Adds cronworkflow.* variables describing the cron object's identity, labels/annotations, and run counts. |
workflow-start (20 variables)¶
| Key | Kind | Type |
|---|---|---|
workflow.annotations |
global | json |
workflow.annotations.<name> |
global | string |
workflow.annotations.json |
global | json |
workflow.creationTimestamp |
global | string |
workflow.creationTimestamp.<fmt> |
global | string |
workflow.creationTimestamp.RFC3339 |
global | string |
workflow.creationTimestamp.s |
global | string |
workflow.labels |
global | json |
workflow.labels.<name> |
global | string |
workflow.labels.json |
global | json |
workflow.mainEntrypoint |
global | string |
workflow.name |
global | string |
workflow.namespace |
global | string |
workflow.parameters |
global | json |
workflow.parameters.<name> |
global | string |
workflow.parameters.json |
global | json |
workflow.priority |
global | string |
workflow.scheduledTime |
global | string |
workflow.serviceAccountName |
global | string |
workflow.uid |
global | string |
pre-dispatch (26 variables)¶
| Key | Kind | Type |
|---|---|---|
node.name |
node-ctx | string |
pod.name |
node-ctx | string |
steps.name |
node-ctx | string |
tasks.name |
node-ctx | string |
workflow.annotations |
global | json |
workflow.annotations.<name> |
global | string |
workflow.annotations.json |
global | json |
workflow.creationTimestamp |
global | string |
workflow.creationTimestamp.<fmt> |
global | string |
workflow.creationTimestamp.RFC3339 |
global | string |
workflow.creationTimestamp.s |
global | string |
workflow.duration |
runtime | string |
workflow.labels |
global | json |
workflow.labels.<name> |
global | string |
workflow.labels.json |
global | json |
workflow.mainEntrypoint |
global | string |
workflow.name |
global | string |
workflow.namespace |
global | string |
workflow.parameters |
global | json |
workflow.parameters.<name> |
global | string |
workflow.parameters.json |
global | json |
workflow.priority |
global | string |
workflow.scheduledTime |
global | string |
workflow.serviceAccountName |
global | string |
workflow.status |
runtime | string |
workflow.uid |
global | string |
during-execute (34 variables)¶
| Key | Kind | Type |
|---|---|---|
inputs.artifacts.<name> |
input | wfv1.Artifact |
inputs.artifacts.<name>.path |
input | string |
inputs.parameters |
input | json |
inputs.parameters.<name> |
input | string |
node.name |
node-ctx | string |
outputs.artifacts.<name>.path |
output | string |
outputs.parameters.<name>.path |
output | string |
pod.name |
node-ctx | string |
steps.name |
node-ctx | string |
tasks.name |
node-ctx | string |
workflow.annotations |
global | json |
workflow.annotations.<name> |
global | string |
workflow.annotations.json |
global | json |
workflow.creationTimestamp |
global | string |
workflow.creationTimestamp.<fmt> |
global | string |
workflow.creationTimestamp.RFC3339 |
global | string |
workflow.creationTimestamp.s |
global | string |
workflow.duration |
runtime | string |
workflow.labels |
global | json |
workflow.labels.<name> |
global | string |
workflow.labels.json |
global | json |
workflow.mainEntrypoint |
global | string |
workflow.name |
global | string |
workflow.namespace |
global | string |
workflow.outputs.artifacts.<name> |
node-ref | wfv1.Artifact |
workflow.outputs.parameters.<name> |
node-ref | string |
workflow.parameters |
global | json |
workflow.parameters.<name> |
global | string |
workflow.parameters.json |
global | json |
workflow.priority |
global | string |
workflow.scheduledTime |
global | string |
workflow.serviceAccountName |
global | string |
workflow.status |
runtime | string |
workflow.uid |
global | string |
inside-loop (2 variables)¶
| Key | Kind | Type |
|---|---|---|
item |
item | string or json |
item.<key> |
item | string |
inside-retry (5 variables)¶
| Key | Kind | Type |
|---|---|---|
lastRetry.duration |
retry | string |
lastRetry.exitCode |
retry | string |
lastRetry.message |
retry | string |
lastRetry.status |
retry | string |
retries |
retry | string |
after-node-init (6 variables)¶
| Key | Kind | Type |
|---|---|---|
steps.<name>.id |
node-ref | string |
steps.<name>.startedAt |
node-ref | string |
steps.<name>.status |
node-ref | string |
tasks.<name>.id |
node-ref | string |
tasks.<name>.startedAt |
node-ref | string |
tasks.<name>.status |
node-ref | string |
after-pod-start (4 variables)¶
| Key | Kind | Type |
|---|---|---|
steps.<name>.hostNodeName |
node-ref | string |
steps.<name>.ip |
node-ref | string |
tasks.<name>.hostNodeName |
node-ref | string |
tasks.<name>.ip |
node-ref | string |
after-node-complete (4 variables)¶
| Key | Kind | Type |
|---|---|---|
steps.<name>.exitCode |
node-ref | string |
steps.<name>.finishedAt |
node-ref | string |
tasks.<name>.exitCode |
node-ref | string |
tasks.<name>.finishedAt |
node-ref | string |
after-node-succeeded (6 variables)¶
| Key | Kind | Type |
|---|---|---|
steps.<name>.outputs.artifacts.<a> |
node-ref | wfv1.Artifact |
steps.<name>.outputs.parameters.<p> |
node-ref | string |
steps.<name>.outputs.result |
node-ref | string |
tasks.<name>.outputs.artifacts.<a> |
node-ref | wfv1.Artifact |
tasks.<name>.outputs.parameters.<p> |
node-ref | string |
tasks.<name>.outputs.result |
node-ref | string |
after-loop (6 variables)¶
| Key | Kind | Type |
|---|---|---|
steps.<loopName>.outputs.parameters |
node-ref | json |
steps.<loopName>.outputs.parameters.<p> |
node-ref | json |
steps.<loopName>.outputs.result |
node-ref | json |
tasks.<loopName>.outputs.parameters |
node-ref | json |
tasks.<loopName>.outputs.parameters.<p> |
node-ref | json |
tasks.<loopName>.outputs.result |
node-ref | json |
exit-handler (55 variables)¶
| Key | Kind | Type |
|---|---|---|
inputs.artifacts.<name>.path |
input | string |
outputs.artifacts.<name>.path |
output | string |
outputs.parameters.<name>.path |
output | string |
pod.name |
node-ctx | string |
steps.<loopName>.outputs.parameters |
node-ref | json |
steps.<loopName>.outputs.parameters.<p> |
node-ref | json |
steps.<loopName>.outputs.result |
node-ref | json |
steps.<name>.exitCode |
node-ref | string |
steps.<name>.finishedAt |
node-ref | string |
steps.<name>.hostNodeName |
node-ref | string |
steps.<name>.id |
node-ref | string |
steps.<name>.ip |
node-ref | string |
steps.<name>.outputs.artifacts.<a> |
node-ref | wfv1.Artifact |
steps.<name>.outputs.parameters.<p> |
node-ref | string |
steps.<name>.outputs.result |
node-ref | string |
steps.<name>.startedAt |
node-ref | string |
steps.<name>.status |
node-ref | string |
tasks.<loopName>.outputs.parameters |
node-ref | json |
tasks.<loopName>.outputs.parameters.<p> |
node-ref | json |
tasks.<loopName>.outputs.result |
node-ref | json |
tasks.<name>.exitCode |
node-ref | string |
tasks.<name>.finishedAt |
node-ref | string |
tasks.<name>.hostNodeName |
node-ref | string |
tasks.<name>.id |
node-ref | string |
tasks.<name>.ip |
node-ref | string |
tasks.<name>.outputs.artifacts.<a> |
node-ref | wfv1.Artifact |
tasks.<name>.outputs.parameters.<p> |
node-ref | string |
tasks.<name>.outputs.result |
node-ref | string |
tasks.<name>.startedAt |
node-ref | string |
tasks.<name>.status |
node-ref | string |
workflow.annotations |
global | json |
workflow.annotations.<name> |
global | string |
workflow.annotations.json |
global | json |
workflow.creationTimestamp |
global | string |
workflow.creationTimestamp.<fmt> |
global | string |
workflow.creationTimestamp.RFC3339 |
global | string |
workflow.creationTimestamp.s |
global | string |
workflow.duration |
runtime | string |
workflow.failures |
runtime | json |
workflow.labels |
global | json |
workflow.labels.<name> |
global | string |
workflow.labels.json |
global | json |
workflow.mainEntrypoint |
global | string |
workflow.name |
global | string |
workflow.namespace |
global | string |
workflow.outputs.artifacts.<name> |
node-ref | wfv1.Artifact |
workflow.outputs.parameters.<name> |
node-ref | string |
workflow.parameters |
global | json |
workflow.parameters.<name> |
global | string |
workflow.parameters.json |
global | json |
workflow.priority |
global | string |
workflow.scheduledTime |
global | string |
workflow.serviceAccountName |
global | string |
workflow.status |
runtime | string |
workflow.uid |
global | string |
metric-emission (6 variables)¶
| Key | Kind | Type |
|---|---|---|
duration |
metric | string |
exitCode |
metric | string |
outputs.parameters.<name> |
metric | string |
outputs.result |
metric | string |
resourcesDuration.<resource> |
metric | string |
status |
metric | string |
cron-eval (9 variables)¶
| Key | Kind | Type |
|---|---|---|
cronworkflow.annotations |
cron-workflow | map |
cronworkflow.annotations.json |
cron-workflow | json |
cronworkflow.failed |
cron-workflow | int |
cronworkflow.labels |
cron-workflow | map |
cronworkflow.labels.json |
cron-workflow | json |
cronworkflow.lastScheduledTime |
cron-workflow | *time.Time |
cronworkflow.name |
cron-workflow | string |
cronworkflow.namespace |
cron-workflow | string |
cronworkflow.succeeded |
cron-workflow | int |
5. Showcase workflow¶
The runnable example below exercises the variables catalogued above. It is embedded at docs-build time from examples/variables-showcase.yaml (the same file the example tests validate and run).
# Companion to variables.md — exercises every non-cron-workflow variable
# documented in the catalog. Every reference is annotated inline with the
# catalog row it covers. CronWorkflow-only variables are intentionally omitted.
#
# Coverage map (74 variables):
#
# Global (20) workflow.* identity / metadata / parameters
# Runtime (3) workflow.duration / .status / .failures
# Input (4) inputs.parameters{,.<n>}, inputs.artifacts.<n>{,.path}
# Output (2) outputs.{parameters,artifacts}.<n>.path
# Node-Ref (28) steps.<*>.* and tasks.<*>.* including after-loop
# aggregates and workflow.outputs.{parameters,artifacts}.<n>
# Item (2) item / item.<key>
# Retry (5) lastRetry.* / retries
# Node-Ctx (4) node.name / pod.name / steps.name / tasks.name
# Metric (6) duration / exitCode / status / outputs.result /
# outputs.parameters.<n> / resourcesDuration.<r>
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: variables-showcase-
annotations:
# `workflow.scheduledTime` is sourced from this annotation.
workflows.argoproj.io/scheduled-time: "2026-04-29T00:00:00Z"
# Used to demonstrate workflow.annotations / .annotations.json /
# .annotations.<name>.
workflows.argoproj.io/description: "Showcase of every non-cronworkflow variable"
example.io/owner: platform-team
labels:
# Used to demonstrate workflow.labels / .labels.json / .labels.<name>.
app: variables-demo
tier: example
spec:
entrypoint: main
serviceAccountName: default # → workflow.serviceAccountName (executor role bound)
priority: 5 # → workflow.priority
onExit: exit-handler # required for workflow.failures + the
# final values of workflow.{status,duration}
arguments: # → workflow.parameters / .parameters.<n> / .parameters.json
parameters:
- name: greeting
value: hello
- name: target
value: world
artifacts:
- name: seed # consumed via workflow.parameters → prepared
raw:
data: seed-content
templates:
# ============================================================
# 1. main — Steps body. Exercises:
# steps.name (node-ctx)
# steps.<name>.{id,status,startedAt,finishedAt,hostNodeName,
# ip,exitCode,outputs.{result,parameters.<p>,
# artifacts.<a>}}
# steps.<loopName>.outputs.{result, parameters,
# parameters.<p>} (after-loop)
# Declares `seed` as an input artifact so that inputs.artifacts.<name>
# (the wfv1.Artifact object form, distinct from the `.path` accessor)
# can be referenced via `from:` on a downstream argument.
# ============================================================
- name: main
inputs:
artifacts:
- name: seed # bound from spec.arguments.artifacts.seed
steps:
- - name: prepare
template: prepare
- name: svc # daemon — validator only exposes .ip on daemons
template: svc-daemon
- - name: fanout # withItems → item / item.<key>
template: per-item
arguments:
parameters:
- name: msg
value: "{{item.k}}={{item.v}}" # item.<key>
- name: ctx
value: "{{item}}" # item
artifacts:
- name: in-art
from: "{{steps.prepare.outputs.artifacts.prepared}}" # steps.<name>.outputs.artifacts.<a>
withItems:
- { k: alpha, v: "1" }
- { k: beta, v: "2" }
- - name: consume
template: consume
arguments:
parameters:
# ---- after-loop on steps.<loopName> ----
- { name: fanout-result, value: "{{steps.fanout.outputs.result}}" }
- { name: fanout-all-params, value: "{{steps.fanout.outputs.parameters}}" }
- { name: fanout-named-params, value: "{{steps.fanout.outputs.parameters.echoed}}" }
# ---- node-ref on a non-loop step (prepare) ----
- { name: prep-id, value: "{{steps.prepare.id}}" }
- { name: prep-status, value: "{{steps.prepare.status}}" }
- { name: prep-host, value: "{{steps.prepare.hostNodeName}}" }
- { name: svc-ip, value: "{{steps.svc.ip}}" } # ip only valid on daemon
- { name: prep-started, value: "{{steps.prepare.startedAt}}" }
- { name: prep-finished, value: "{{steps.prepare.finishedAt}}" }
- { name: prep-exit, value: "{{steps.prepare.exitCode}}" }
- { name: prep-result, value: "{{steps.prepare.outputs.result}}" }
- { name: prep-param, value: "{{steps.prepare.outputs.parameters.greeting-out}}" }
# ---- current-step name (Steps body context) ----
- { name: step-name, value: "{{steps.name}}" }
artifacts:
# `inputs.artifacts.<name>` (wfv1.Artifact object form):
# main's own input artifact forwarded to a child via `from:`.
- name: seed-art
from: "{{inputs.artifacts.seed}}"
- - name: dag-stage
template: dag
# ============================================================
# 2. prepare — Script template. Exercises:
# identity: workflow.{name, namespace, uid, mainEntrypoint,
# serviceAccountName, priority}
# timestamps: workflow.creationTimestamp{,.RFC3339,.s,.<fmt>}
# + workflow.scheduledTime
# metadata: workflow.{annotations, annotations.json,
# annotations.<n>, labels, labels.json,
# labels.<n>, parameters, parameters.json,
# parameters.<n>}
# runtime: workflow.{duration, status}
# node-ctx: node.name, pod.name, steps.name
# output ptr: outputs.{parameters,artifacts}.<n>.path
# metric: duration, exitCode, status, outputs.result,
# outputs.parameters.<n>, resourcesDuration.<r>
# Globals are emitted via globalName so workflow.outputs.* is
# populated for the exit handler.
# ============================================================
- name: prepare
metrics:
prometheus:
- name: prepare_seconds
help: Elapsed seconds for the prepare node.
labels:
- { key: phase, value: "{{status}}" }
- { key: code, value: "{{exitCode}}" }
- { key: param, value: "{{outputs.parameters.greeting-out}}" }
- { key: result, value: "{{outputs.result}}" }
- { key: cpu, value: "{{resourcesDuration.cpu}}" }
- { key: mem, value: "{{resourcesDuration.memory}}" }
gauge:
realtime: false
value: "{{duration}}"
outputs:
parameters:
- name: greeting-out
valueFrom:
path: /tmp/out.txt # → outputs.parameters.<n>.path
globalName: prepared-param # → workflow.outputs.parameters.prepared-param
artifacts:
- name: prepared
path: /tmp/payload.txt # → outputs.artifacts.<n>.path
globalName: prepared # → workflow.outputs.artifacts.prepared
script:
image: alpine:3.23
command: [sh]
source: |
set -eu
# ---- node-ctx ----
echo "node.name = {{node.name}}"
echo "pod.name = {{pod.name}}"
echo "steps.name = {{steps.name}}"
# ---- identity ----
echo "workflow.name = {{workflow.name}}"
echo "workflow.namespace = {{workflow.namespace}}"
echo "workflow.uid = {{workflow.uid}}"
echo "workflow.entrypoint = {{workflow.mainEntrypoint}}"
echo "workflow.sa = {{workflow.serviceAccountName}}"
echo "workflow.priority = {{workflow.priority}}"
# ---- timestamps ----
echo "ts.raw = {{workflow.creationTimestamp}}"
echo "ts.RFC3339 = {{workflow.creationTimestamp.RFC3339}}"
echo "ts.epoch-seconds = {{workflow.creationTimestamp.s}}"
echo "ts.year (strftime) = {{workflow.creationTimestamp.Y}}"
echo "ts.scheduled = {{workflow.scheduledTime}}"
# ---- metadata maps ----
echo "annotations.deprec = {{workflow.annotations}}"
echo "annotations.json = {{workflow.annotations.json}}"
echo "annotations.owner = {{workflow.annotations.example.io/owner}}"
echo "labels.deprecated = {{workflow.labels}}"
echo "labels.json = {{workflow.labels.json}}"
echo "labels.app = {{workflow.labels.app}}"
# ---- parameters ----
echo "params.deprecated = {{workflow.parameters}}"
echo "params.json = {{workflow.parameters.json}}"
echo "params.greeting = {{workflow.parameters.greeting}}"
echo "params.target = {{workflow.parameters.target}}"
# ---- runtime ----
echo "workflow.duration = {{workflow.duration}}"
echo "workflow.status = {{workflow.status}}"
# ---- output declared paths (pod-side) ----
echo "out.param.path = {{outputs.parameters.greeting-out.path}}"
echo "out.artifact.path = {{outputs.artifacts.prepared.path}}"
# The final stdout line is captured as outputs.result for this
# script node (exposed downstream as steps.prepare.outputs.result).
printf 'greeting=%s target=%s' '{{workflow.parameters.greeting}}' '{{workflow.parameters.target}}' > /tmp/out.txt
cp /tmp/out.txt /tmp/payload.txt
echo "PREPARED"
# ============================================================
# 3. per-item — Script with retryStrategy. Exercises:
# item, item.<key> (loop scope)
# retries, lastRetry.{duration,exitCode,message,status}
# inputs.parameters, inputs.parameters.<n>
# inputs.artifacts.<n>.path
# inputs.artifacts.<n> (the wfv1.Artifact object, used
# via fromExpression on the relayed
# output artifact)
# ============================================================
- name: per-item
inputs:
parameters:
- name: msg
- name: ctx
artifacts:
- name: in-art
path: /work/in.txt
retryStrategy:
limit: "2"
retryPolicy: OnError
outputs:
parameters:
- name: echoed
valueFrom:
path: /work/echoed.txt
script:
image: alpine:3.23
command: [sh]
source: |
# Loop aggregation parses each child's stdout as JSON, so
# diagnostics go to stderr and the final line on stdout is a
# JSON value.
{
set -eu
# `item` and `item.<key>` are referenced at the call site
# (main → fanout arguments) — the static validator does not
# propagate item scope into inner template bodies.
# ---- inputs ----
echo "inputs.parameters = {{inputs.parameters}}"
echo "inputs.params.msg = {{inputs.parameters.msg}}"
echo "inputs.params.ctx = {{inputs.parameters.ctx}}"
echo "inputs.art.path = {{inputs.artifacts.in-art.path}}"
cat /work/in.txt
# ---- retry ----
echo "retries = {{retries}}"
echo "lastRetry.status = {{lastRetry.status}}"
echo "lastRetry.exitCode = {{lastRetry.exitCode}}"
echo "lastRetry.duration = {{lastRetry.duration}}"
echo "lastRetry.message = {{lastRetry.message}}"
# ---- node-ctx (also valid here) ----
echo "node.name = {{node.name}}"
echo "pod.name = {{pod.name}}"
# ---- output param path ----
echo "out.param.path = {{outputs.parameters.echoed.path}}"
} >&2
printf '%s' '{{inputs.parameters.msg}}' > /work/echoed.txt
# outputs.result must be a JSON value for loop aggregation:
printf '{"msg":"%s"}\n' '{{inputs.parameters.msg}}'
# ============================================================
# 4. consume — receives the after-loop and node-ref values captured
# in the Steps body. Pure-pass-through container.
# ============================================================
- name: consume
inputs:
parameters:
- name: fanout-result
- name: fanout-all-params
- name: fanout-named-params
- name: prep-id
- name: prep-status
- name: prep-host
- name: svc-ip
- name: prep-started
- name: prep-finished
- name: prep-exit
- name: prep-result
- name: prep-param
- name: step-name
artifacts:
- name: seed-art # forwarded from main's inputs.artifacts.seed
path: /tmp/seed.txt
container:
image: alpine:3.23
command: [sh, -c]
args:
- |
echo "fanout.result = {{inputs.parameters.fanout-result}}"
echo "fanout.all-params = {{inputs.parameters.fanout-all-params}}"
echo "fanout.echoed-param = {{inputs.parameters.fanout-named-params}}"
echo "prepare.id = {{inputs.parameters.prep-id}}"
echo "prepare.status = {{inputs.parameters.prep-status}}"
echo "prepare.host = {{inputs.parameters.prep-host}}"
echo "svc.ip = {{inputs.parameters.svc-ip}}"
echo "prepare.startedAt = {{inputs.parameters.prep-started}}"
echo "prepare.finishedAt = {{inputs.parameters.prep-finished}}"
echo "prepare.exitCode = {{inputs.parameters.prep-exit}}"
echo "prepare.result = {{inputs.parameters.prep-result}}"
echo "prepare.param = {{inputs.parameters.prep-param}}"
echo "current step.name = {{inputs.parameters.step-name}}"
echo "seed-art.path = {{inputs.artifacts.seed-art.path}}"
cat /tmp/seed.txt
# ============================================================
# 5. dag — DAG body. Exercises:
# tasks.name (node-ctx)
# tasks.<name>.{id,status,startedAt,finishedAt,hostNodeName,ip,
# exitCode,outputs.{result,parameters.<p>,artifacts.<a>}}
# tasks.<loopName>.outputs.{result, parameters,
# parameters.<p>} (after-loop)
# ============================================================
- name: dag
dag:
tasks:
- name: svc # daemon — for tasks.<n>.ip
template: svc-daemon
- name: a
template: dag-leaf
arguments:
parameters:
- { name: tag, value: "a" }
# tasks.name (node-ctx) is referenced inside dag-leaf's body
# via the local-params substitution path.
- name: b # downstream of a + svc
template: dag-leaf
depends: "a && svc"
arguments:
parameters:
- { name: tag, value: "b" }
# ---- node-ref on tasks.<name> ----
- { name: a-id, value: "{{tasks.a.id}}" }
- { name: a-status, value: "{{tasks.a.status}}" }
- { name: a-host, value: "{{tasks.a.hostNodeName}}" }
- { name: svc-ip, value: "{{tasks.svc.ip}}" } # ip only valid on daemon
- { name: a-started, value: "{{tasks.a.startedAt}}" }
- { name: a-finished, value: "{{tasks.a.finishedAt}}" }
- { name: a-exit, value: "{{tasks.a.exitCode}}" }
- { name: a-result, value: "{{tasks.a.outputs.result}}" }
- { name: a-param, value: "{{tasks.a.outputs.parameters.echoed}}" }
artifacts:
- name: in-art
from: "{{tasks.a.outputs.artifacts.bundle}}" # tasks.<name>.outputs.artifacts.<a>
- name: c-loop # withParam → after-loop
template: dag-leaf
depends: b
arguments:
parameters:
- { name: tag, value: "{{item}}" }
withParam: '["x","y","z"]'
- name: gather
template: dag-gather
depends: c-loop
arguments:
parameters:
- { name: loop-result, value: "{{tasks.c-loop.outputs.result}}" }
- { name: loop-all-params, value: "{{tasks.c-loop.outputs.parameters}}" }
- { name: loop-named-params, value: "{{tasks.c-loop.outputs.parameters.echoed}}" }
# 5a. dag-leaf — Script: produces outputs.result (captured stdout),
# a named output parameter, and a named output artifact.
- name: dag-leaf
inputs:
parameters:
- name: tag
# Optional inputs so the same template handles a, b, and c-loop.
- { name: a-id, value: "" }
- { name: a-status, value: "" }
- { name: a-host, value: "" }
- { name: svc-ip, value: "" }
- { name: a-started, value: "" }
- { name: a-finished, value: "" }
- { name: a-exit, value: "" }
- { name: a-result, value: "" }
- { name: a-param, value: "" }
artifacts:
- { name: in-art, path: /work/in, optional: true }
outputs:
parameters:
- name: echoed
valueFrom:
path: /work/out.txt
artifacts:
- name: bundle
path: /work/bundle.txt
script:
image: alpine:3.23
command: [sh]
source: |
# Same JSON-on-stdout convention as per-item: c-loop calls this
# template via withParam, so its result is loop-aggregated.
{
set -eu
mkdir -p /work
# tasks.name is substituted by the controller's local-params pass
# to the calling task's name (e.g. "a", "b", "c-loop[0]").
echo "tag={{inputs.parameters.tag}} tasks.name={{tasks.name}}"
echo "a-id={{inputs.parameters.a-id}} status={{inputs.parameters.a-status}}"
echo "a-host={{inputs.parameters.a-host}} svc-ip={{inputs.parameters.svc-ip}}"
echo "a-started={{inputs.parameters.a-started}} finished={{inputs.parameters.a-finished}}"
echo "a-exit={{inputs.parameters.a-exit}} result={{inputs.parameters.a-result}}"
echo "a-param={{inputs.parameters.a-param}}"
} >&2
printf 'tag=%s' '{{inputs.parameters.tag}}' > /work/out.txt
cp /work/out.txt /work/bundle.txt
printf '{"tag":"%s"}\n' '{{inputs.parameters.tag}}'
# 5b. dag-gather — receives the after-loop aggregates from c-loop.
- name: dag-gather
inputs:
parameters:
- name: loop-result
- name: loop-all-params
- name: loop-named-params
container:
image: alpine:3.23
command: [sh, -c]
args:
- |
echo "c-loop.result = {{inputs.parameters.loop-result}}"
echo "c-loop.all-params = {{inputs.parameters.loop-all-params}}"
echo "c-loop.named-params = {{inputs.parameters.loop-named-params}}"
# ============================================================
# 5c. svc-daemon — used purely so steps.<name>.ip / tasks.<name>.ip
# pass the static validator's daemon-only check.
# ============================================================
- name: svc-daemon
daemon: true
container:
image: alpine:3.23
command: [sh, -c]
args: ["nc -lk -p 9999 -e /bin/true"]
readinessProbe:
tcpSocket:
port: 9999
initialDelaySeconds: 1
timeoutSeconds: 1
# ============================================================
# 6. exit-handler — onExit template. Exercises:
# workflow.failures (only meaningful here)
# workflow.outputs.parameters.<n>
# workflow.outputs.artifacts.<n>
# final values of workflow.{status,duration}
# Long source goes through inputs.parameters so the YAML stays
# readable and so the exit-handler also exercises a couple of
# input variables.
# ============================================================
- name: exit-handler
steps:
- - name: report
template: exit-report
arguments:
parameters:
- { name: final-status, value: "{{workflow.status}}" }
- { name: final-duration, value: "{{workflow.duration}}" }
- { name: failures, value: "{{workflow.failures}}" }
- { name: global-param, value: "{{workflow.outputs.parameters.prepared-param}}" }
artifacts:
- name: global-art
from: "{{workflow.outputs.artifacts.prepared}}"
- name: exit-report
inputs:
parameters:
- name: final-status
- name: final-duration
- name: failures
- name: global-param
artifacts:
- name: global-art
path: /tmp/global.txt
container:
image: alpine:3.23
command: [sh, -c]
args:
- |
echo "workflow.status = {{inputs.parameters.final-status}}"
echo "workflow.duration = {{inputs.parameters.final-duration}}"
echo "workflow.failures = {{inputs.parameters.failures}}"
echo "workflow.outputs.params.prepared = {{inputs.parameters.global-param}}"
cat /tmp/global.txt