feat(hooks): per-deployment HTTP webhook hooks#1427
Conversation
Add deploy-config `hooks.on_success` / `hooks.on_failure` lists that POST a JSON payload (event, repository, stack, revision, job_id, images, error) to configured endpoints. Fired from the post-deploy stage on success and from NotifyFailure on failure. Best-effort: hook failures are logged and never abort the deployment. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1427 +/- ##
==========================================
+ Coverage 44.92% 44.99% +0.07%
==========================================
Files 130 131 +1
Lines 10858 10934 +76
==========================================
+ Hits 4878 4920 +42
- Misses 5341 5373 +32
- Partials 639 641 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Does this also work with auto-discovery and remote repositories? |
I've already tested on remote repositories in my environments. Let me validate whether it works properly with auto-discovery. |
|
@kimdre I'm sorry for taking too long. Should Doco-cd force to pull an image or recreate a container when the Doco-cd is restarted? [e.g. As I understood your current version will not force when the Doco-cd only restarts. Is it a bug or your intent? |
What
Adds per-deployment HTTP webhook hooks. A deploy config can declare
hooks.on_successandhooks.on_failurelists; each entry POSTs a JSON payload to an endpoint when the deployment succeeds or fails.Why
Lets external systems (CI, alerting, chatops) react to doco-cd deployments without polling — e.g. notify a channel on success or page on failure.
Config
Fields per entry:
url(required, http/https),method(defaultPOST),headers(optional map).Payload
JSON body (
Content-Type: application/json):eventsuccessorfailurerepositorystackrevisionmain (abc1234))job_idimagesname:tag) of the changed services; omitted when emptyerrorBehaviour
StageManager.NotifyFailure.Hooks.Validaterejects empty / non-http(s) URLs).allowOverrideper-target overrides supported.Tests
internal/hook: URL validation, send (method/headers/body), non-2xx + bad-URL paths.internal/config/deploy: hook parsing from YAML, invalid-URL rejection, multi-doc handling.internal/stages:changedServiceImages(dedup/sort, missing-image, nil-project).Notes
imagescurrently reflects only changed services, so it is omitted on deploys with no file-detected service changes (e.g. force-recreate / mismatch-driven redeploys). Can be widened to all stack services if desired.