opschain triggers export
triggers
opschain triggers export <project>/<code> [--out <file.yaml>]
Exports a trigger as its nested when/then interchange YAML, for backup and
change control — git's role here is backup and change control, never
sourcing. The document carries the stored definition exactly (the canonical
artifact spelling included), rendered deterministically so re-exporting an
unchanged trigger is byte-identical and exported files diff cleanly:
trigger: promote_on_success
description: promote dev web deploys
enabled: true
when:
subject: change
events:
- finished
scope: /projects/demo/environments/dev
conditions:
- event.source.action eq web:deploy
then:
create: workflow_run
with:
workflow: release
enabled is always carried; name only when it differs from the code,
when.subject only when it is not the default external, and
throttle_per_minute only when it differs from the column default (60).
then.run_as carries the firing identity and the top-level owned_by
the owning group, each only when one is set.
This nested document is deliberately not the flat attribute format
triggers create -f loads — each loader rejects the other's format by name.
Without --out the bare YAML goes to stdout, redirectable; with it, the
file is written and exported trigger <project>/<code> to <file> confirms.
Needs a server target (--server <url>, OPSCHAIN_SERVER, or the active
context).
Flags
| Flag | Meaning |
|---|---|
--out <file> | Write the YAML to this file instead of stdout. |
Exit codes
| Code | Meaning |
|---|---|
| 0 | Exported. |
| 1 | The command failed (trigger not found, server error, unwritable file). |
| 2 | Usage error — malformed address, no server target. |
Named errors
expected <project>/<trigger-code>, got "<arg>"— exit 2.trigger "<code>" not found in project "<project>"— exit 1.
See also
opschain docs cli/triggers-import— the other half of the round trip.opschain docs cli/triggers-show— the definition rendered for reading.opschain learn 8.1(backup and interchange).