Skip to main content
Version: v5.6.1

opschain step set-output

Included from Basic tier

opschain step set-output <key> [<value>]

Publishes one output from inside a running step for later steps' ${{ steps.<name>.outputs.<key> }} references. The pair is appended as a key=value line to the file named by $OPSCHAIN_OUTPUT — or, with --sensitive, by $OPSCHAIN_OUTPUT_SENSITIVE — and applied by the engine when the step succeeds. A repeated key keeps its last value.

Keys must match ^[a-z0-9_]{1,50}$. Values are single-line (the outputs file is key=value per line); multi-line data belongs in an artifact. A step's outputs (keys plus values, plain and sensitive files combined) share a 64 KiB budget — a value over it is refused here, with the budget named, instead of failing the step at collection. A plain output whose value matches a masked secret fails the step at finalisation — publish it as a sensitive output or keep it in the secret vault.

--value-file reads the value from a file (- reads stdin) for values beyond OS argument limits, e.g. base64-encoded report bodies; a single trailing newline is dropped. Pass the value as an argument or via --value-file, not both.

Flags​

FlagMeaning
--sensitiveTreat the value as sensitive: stored encrypted, masked in later step logs, redacted on API reads.
--value-fileRead the value from this file instead of the argument (- reads stdin).

Environment​

VariableMeaning
OPSCHAIN_OUTPUTThe plain outputs file this command appends to (set by the executor).
OPSCHAIN_OUTPUT_SENSITIVEThe sensitive outputs file --sensitive appends to instead.

Exit codes​

CodeMeaning
0Output recorded.
1The outputs file could not be written.
2Usage error (bad key, multi-line value, value over the output budget, not inside a step).

Named errors​

  • output key "<key>" must match ^[a-z0-9_]{1,50}$
  • output values are single-line (the outputs file is key=value per line): store multi-line data as an artifact instead
  • output "<key>" is <n> bytes — a step's outputs share a 65536-byte budget: publish large data as an artifact, or leave it in the step log
  • pass the value as an argument or via --value-file, not both
  • a value is required: pass it as an argument or via --value-file
  • $OPSCHAIN_OUTPUT is not set: opschain step subcommands only work inside a running OpsChain step

All exit 2.

Examples​

opschain step set-output image_tag v2.3.1
opschain step set-output api_key "$GENERATED_KEY" --sensitive
opschain step set-output report_md_b64 --value-file report.b64
base64 < report.md | tr -d '\n' | opschain step set-output report_md_b64 --value-file -

See also​

  • opschain docs artifacts — declare report or dist files as step artifacts instead of base64-folding them into outputs; the budget stays, artifacts are the transport for anything larger.
  • opschain docs cli/step-set-property — persist a value into properties instead of handing it to the next step.
  • opschain learn 2.1 — consuming outputs in YAML actions.