mirror of
https://github.com/argoproj/argo-cd
synced 2026-05-24 09:50:08 +00:00
Add a hook example for sending a Slack message (#2414)
This commit is contained in:
parent
dd21ab92ad
commit
f116bd3588
1 changed files with 52 additions and 0 deletions
|
|
@ -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
|
||||
```
|
||||
|
|
|
|||
Loading…
Reference in a new issue