diff --git a/docs/user-guide/resource_hooks.md b/docs/user-guide/resource_hooks.md index 9a03798a16..c4d6b3bdcf 100644 --- a/docs/user-guide/resource_hooks.md +++ b/docs/user-guide/resource_hooks.md @@ -77,3 +77,55 @@ field in the spec, which let their respective controllers delete the Job/Workflo spec: ttlSecondsAfterFinished: 600 ``` + +## Using A Hook To Send A Slack Message + +The following example uses the Slack API to send a a Slack message when sync completes or fails: + +```yaml +apiVersion: batch/v1 +kind: Job +metadata: + generateName: app-slack-notification- + annotations: + argocd.argoproj.io/hook: PostSync + argocd.argoproj.io/hook-delete-policy: HookSucceeded +spec: + template: + spec: + containers: + - name: slack-notification + image: appropriate/curl + command: + - "curl" + - "-X" + - "POST" + - "--data-urlencode" + - "payload={\"channel\": \"#somechannel\", \"username\": \"hello\", \"text\": \"App Sync succeeded\", \"icon_emoji\": \":ghost:\"}" + - "https://hooks.slack.com/services/..." + restartPolicy: Never + backoffLimit: 2 +--- +apiVersion: batch/v1 +kind: Job +metadata: + generateName: app-slack-notification-fail- + annotations: + argocd.argoproj.io/hook: SyncFail + argocd.argoproj.io/hook-delete-policy: HookSucceeded +spec: + template: + spec: + containers: + - name: slack-notification + image: appropriate/curl + command: + - "curl" + - "-X" + - "POST" + - "--data-urlencode" + - "payload={\"channel\": \"#somechannel\", \"username\": \"hello\", \"text\": \"App Sync failed\", \"icon_emoji\": \":ghost:\"}" + - "https://hooks.slack.com/services/..." + restartPolicy: Never + backoffLimit: 2 + ```