ARGO CD SLACK INTEGRATION
Note : Update the Slack Token and ArgoCD URL in the ConfigMap before applying it to your cluster.FileName : argo-configmap.yaml
Copy
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
namespace: argocd
data:
# ---------------------------------------------------------------------------
# 1. CONTEXT (Fixes the <no value> link issue)
# ---------------------------------------------------------------------------
context: |
argocdUrl: http://argo-uat.internal.com
# ---------------------------------------------------------------------------
# 2. SLACK TOKEN & SETTINGS
# ---------------------------------------------------------------------------
service.slack: |
token: xoxb-xxx-xxxxxxxxxx-xxxxxxxxxxxx
username: ArgoCD
# ---------------------------------------------------------------------------
# 3. SUBSCRIPTIONS
# ---------------------------------------------------------------------------
subscriptions: |
- recipients:
- slack:jenkins-ntfy
triggers:
- on-sync-succeeded
- on-sync-failed
- on-health-degraded
- on-deployed
# ---------------------------------------------------------------------------
# 4. TRIGGERS
# ---------------------------------------------------------------------------
trigger.on-sync-succeeded: |
- description: Application syncing has succeeded
send: [app-sync-succeeded]
when: app.status.operationState.phase in ['Succeeded'] and app.status.health.status == 'Healthy'
trigger.on-sync-failed: |
- description: Application syncing has failed
send: [app-sync-failed]
when: app.status.operationState.phase in ['Error', 'Failed']
trigger.on-health-degraded: |
- description: Application has degraded
send: [app-health-degraded]
when: app.status.health.status == 'Degraded'
# trigger.on-deployed: |
# - description: Application is synced and healthy. Triggered once per commit.
# oncePer: app.status.operationState.syncResult.revision
# send: [app-deployed]
# when: app.status.operationState.phase in ['Succeeded'] and app.status.health.status == 'Healthy'
# ---------------------------------------------------------------------------
# 5. TEMPLATES (With Action Details: Configured/Created)
# ---------------------------------------------------------------------------
# ✅ SYNC SUCCEEDED
template.app-sync-succeeded: |
message: |
🚀 Application {{.app.metadata.name}} Synced.
slack:
attachments: |
[{
"color": "#18be52",
"title": "✅ Sync Succeeded: {{.app.metadata.name}}",
"title_link": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}",
"fields": [
{
"title": "Application",
"value": "<{{.context.argocdUrl}}/applications/{{.app.metadata.name}}|{{.app.metadata.name}}>",
"short": true
},
{
"title": "Repo URL",
"value": "{{.app.spec.source.repoURL}}",
"short": true
},
{
"title": "Commit",
"value": "`{{.app.status.operationState.syncResult.revision}}`",
"short": true
},
{
"title": "Status",
"value": "Sync: {{.app.status.operationState.phase}}\nHealth: {{.app.status.health.status}}",
"short": true
},
{
"title": "📦 Changed Objects",
"value": "```{{range .app.status.operationState.syncResult.resources}}• {{.kind}} {{.name}}: {{.message}}\n{{end}}```",
"short": false
}
],
"footer": "Argo CD"
}]
# ❌ SYNC FAILED
template.app-sync-failed: |
message: |
❌ Application {{.app.metadata.name}} Failed to Sync.
slack:
attachments: |
[{
"color": "#ff0000",
"title": "❌ Sync Failed: {{.app.metadata.name}}",
"title_link": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}",
"fields": [
{
"title": "Application",
"value": "<{{.context.argocdUrl}}/applications/{{.app.metadata.name}}|{{.app.metadata.name}}>",
"short": true
},
{
"title": "Error Message",
"value": "```{{.app.status.operationState.message}}```",
"short": false
},
{
"title": "Commit",
"value": "`{{.app.status.operationState.syncResult.revision}}`",
"short": true
}
],
"footer": "Argo CD"
}]
# ⚠️ HEALTH DEGRADED
template.app-health-degraded: |
message: |
⚠️ Application {{.app.metadata.name}} is Degraded.
slack:
attachments: |
[{
"color": "#ffca00",
"title": "⚠️ Health Degraded: {{.app.metadata.name}}",
"title_link": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}",
"fields": [
{
"title": "Application",
"value": "<{{.context.argocdUrl}}/applications/{{.app.metadata.name}}|{{.app.metadata.name}}>",
"short": true
},
{
"title": "Health Status",
"value": "{{.app.status.health.status}}",
"short": true
}
],
"footer": "Argo CD"
}]
# # 🚀 DEPLOYED
# template.app-deployed: |
# message: |
# 🚀 New Version Deployed: {{.app.metadata.name}}
# slack:
# attachments: |
# [{
# "color": "#2eb886",
# "title": "🚀 Deployed: {{.app.metadata.name}}",
# "title_link": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}",
# "fields": [
# {
# "title": "Application",
# "value": "<{{.context.argocdUrl}}/applications/{{.app.metadata.name}}|{{.app.metadata.name}}>",
# "short": true
# },
# {
# "title": "New Commit",
# "value": "`{{.app.status.operationState.syncResult.revision}}`",
# "short": true
# },
# {
# "title": "📦 Affected Objects",
# "value": "```{{range .app.status.operationState.syncResult.resources}}• {{.kind}} {{.name}} -> {{.message}}\n{{end}}```",
# "short": false
# }
# ],
# "footer": "Argo CD"
# }]
