Slack
Configuration¶
- Create Slack Application using https://api.slack.com/apps?new_app=1
- Once application is created navigate to
Enter OAuth & Permissions
- Click
Permissions
underAdd features and functionality
section and addchat:write:bot
scope. To use the optional username and icon overrides in the Slack notification service also add thechat:write.customize
scope. - Scroll back to the top, click 'Install App to Workspace' button and confirm the installation.
-
Once installation is completed copy the OAuth token.
-
Finally use the OAuth token to configure the slack integration in the
argocd-notifications-secret
secret:
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
data:
service.slack: |
apiURL: <url> # optional URL, e.g. https://my-mattermost-url.com/api
token: $slack-token
username: <override-username> # optional username
icon: <override-icon> # optional icon for the message (supports both emoij and url notation)
apiVersion: v1
kind: Secret
metadata:
name: argocd-notifications-secret
stringData:
token: <auth-token>
Templates¶
Notification templates can be customized to leverage slack message blocks and attachments feature.
The message blocks and attachments can be specified in blocks
and attachments
string fields under slack
field:
template.app-sync-status: |
message: |
Application {{.app.metadata.name}} sync is {{.app.status.sync.status}}.
Application details: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}.
slack:
attachments: |
[{
"title": "{{.app.metadata.name}}",
"title_link": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}",
"color": "#18be52",
"fields": [{
"title": "Sync Status",
"value": "{{.app.status.sync.status}}",
"short": true
}, {
"title": "Repository",
"value": "{{.app.spec.source.repoURL}}",
"short": true
}]
}]