Google Chat
Parameters
The Google Chat notification service send message notifications to a google chat webhook. This service uses the following settings:
webhooks- a map of the formwebhookName: webhookUrl
Configuration
- Open
Google chatand go to the space to which you want to send messages - From the menu at the top of the page, select Configure Webhooks
- Under Incoming Webhooks, click Add Webhook
- Give a name to the webhook, optionally add an image and click Save
- Copy the URL next to your webhook
- Store the URL in
argocd-notification-secretand declare it inargocd-notifications-cm
apiVersion: v1kind: ConfigMapmetadata:name: <config-map-name>data:service.googlechat: |webhooks:spaceName: $space-webhook-url
apiVersion: v1kind: Secretmetadata:name: <secret-name>stringData:space-webhook-url: https://chat.googleapis.com/v1/spaces/<space_id>/messages?key=<key>&token=<token>
- Create a subscription for your space
apiVersion: argoproj.io/v1alpha1kind: Applicationmetadata:annotations:notifications.argoproj.io/subscribe.on-sync-succeeded.googlechat: spaceName
Templates
You can send simple text or card messages to a Google Chat space. A simple text message template can be defined as follows:
template.app-sync-succeeded: |message: The app {{ .app.metadata.name }} has successfully synced!
A card message can be defined as follows:
template.app-sync-succeeded: |googlechat:cards: |- header:title: ArgoCD Bot Notificationsections:- widgets:- textParagraph:text: The app {{ .app.metadata.name }} has successfully synced!- widgets:- keyValue:topLabel: Repositorycontent: {{ call .repo.RepoURLToHTTPS .app.spec.source.repoURL }}- keyValue:topLabel: Revisioncontent: {{ .app.spec.source.targetRevision }}- keyValue:topLabel: Authorcontent: {{ (call .repo.GetCommitMetadata .app.status.sync.revision).Author }}
The card message can be written in JSON too.
Chat Threads
It is possible send both simple text and card messages in a chat thread by specifying a unique key for the thread. The thread key can be defined as follows:
template.app-sync-succeeded: |message: The app {{ .app.metadata.name }} has succesfully synced!googlechat:threadKey: {{ .app.metadata.name }}