Skip to main content
Version: v5.7.0

opschain triggers update

triggers

opschain triggers update <project>/<code> [-f <file.yaml>] [--condition <expr> ...]
[--throttle <n>] [--run-as <username>] [--owned-by <group>]

Updates parts of a trigger, sending only what is supplied (PATCH /api/projects/{project}/triggers/{id}); unsupplied attributes keep their stored values. At least one of the five flags must be passed.

The sources overlay in this order — a flag wins over the file for the attribute it names:

  1. -f <file.yaml> — the same flat attribute format triggers create loads, strictly checked against the same accepted key set. Every attribute in the file is sent except code: code is immutable, and a file whose code disagrees with the addressed trigger is refused.
  2. --condition (repeatable) — a replacement conditions list. It REPLACES the stored conditions array wholesale; there is no append.
  3. --throttle <n> — a new throttle_per_minute. Sent whenever the flag is passed, 0 included.
  4. --run-as <username> — the identity the trigger's firings execute and authorisation-check as. Setting it requires your act_as trust grant for that identity on the project; --run-as "" clears it. Service accounts (opschain admin service-accounts) are the durable choice for anything a team depends on.
  5. --owned-by <group> — the group that owns this automation: maintenance and failure-notification accountability routes to the team, surviving individual departures. Must name a known group (local or provider snapshot); --owned-by "" clears it.

On success: updated trigger <project>/<code> (-o json|yaml prints the server's response document instead). Needs a server target (--server <url>, OPSCHAIN_SERVER, or the active context).

Flags​

FlagMeaning
-f, --file <file>Flat YAML definition — every attribute in it is sent (except code).
--condition <expr>Replacement condition event.<path> <op> <value> (repeatable; REPLACES the stored conditions array).
--throttle <n>New throttle_per_minute.
--run-as <username>Identity this trigger's firings execute as (needs your act_as trust grant; "" clears).
--owned-by <group>Group owning this automation — routes its notifications and maintenance to the team ("" clears).

Exit codes​

CodeMeaning
0Trigger updated.
1The command failed (trigger not found, server refused the update).
2Usage error — nothing to send, invalid file, code mismatch, no server target.

Named errors​

  • nothing to update — pass -f, --condition, --throttle, --run-as and/or --owned-by — exit 2.
  • <file> defines code "<other>" but the command addresses <project>/<code> — code is immutable — exit 2.
  • <file>: unknown trigger attribute(s) <keys> (accepted: …) and <file> is a trigger interchange document (trigger/when/then) — load it with opschain triggers import`` — the create loader's checks, exit 2.
  • trigger "<code>" not found in project "<project>" — exit 1.

Examples​

opschain triggers update demo/promote_on_success --throttle 10
opschain triggers update demo/promote_on_success \
--condition "event.source.action eq web:deploy" \
--condition "event.data.region in syd,mel"
opschain triggers update demo/promote_on_success --run-as release-bot
opschain triggers update demo/promote_on_success --owned-by platform-team

See also​

  • opschain docs cli/triggers-create — the file format.
  • opschain docs cli/triggers-enable and opschain docs cli/triggers-disable — the dedicated enabled-flag verbs.
  • opschain docs cli/triggers-import — full replacement from an exported document.