Hooks

Run your own scripts for provisioning, rollbacks, drift fixes and more.

A hook is a command you set on the agent. When its job arrives, the agent runs it with validated values in environment variables. The agent's own token is never passed to a hook.

  • STRATACORE_PROVISION_CMD: PR_NUMBER, BRANCH, SHA, REPO, PREVIEW_URL
  • STRATACORE_ROLLBACK_CMD: SERVICE, TO_VERSION
  • STRATACORE_WEIGHT_CMD: SERVICE, VERSION, WEIGHT (traffic percentage for a canary). Optional: without it the weight is tracked in the console only.
  • STRATACORE_DRIFT_CMD: SERVICE, DECLARED_JSON, DIFF_JSON
  • STRATACORE_RIGHTSIZE_CMD: SERVICE, CPU, RAM_GB
  • STRATACORE_SCAFFOLD_CMD: TEMPLATE, SERVICE, REPO

Rollbacks, applying a drift fix, rightsizing, canary traffic weights and template scaffolding need a hook: the agent does not know how your infrastructure is built, so it does not guess. Pausing, waking and removing previews needs no hook.

Example: provision hook

#!/bin/sh
set -eu
cd /srv/apps/web
git fetch origin "$SHA" && git checkout "$SHA"
docker compose -p "pr-$PR_NUMBER" up -d --build
Values arrive already checked against strict patterns, but always quote them in your scripts.