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 form webhookName: webhookUrl

Configuration

  1. Open Google chat and go to the space to which you want to send messages
  2. From the menu at the top of the page, select Configure Webhooks
  3. Under Incoming Webhooks, click Add Webhook
  4. Give a name to the webhook, optionally add an image and click Save
  5. Copy the URL next to your webhook
  6. Store the URL in argocd-notification-secret and declare it in argocd-notifications-cm
  1. apiVersion: v1
  2. kind: ConfigMap
  3. metadata:
  4. name: <config-map-name>
  5. data:
  6. service.googlechat: |
  7. webhooks:
  8. spaceName: $space-webhook-url
  1. apiVersion: v1
  2. kind: Secret
  3. metadata:
  4. name: <secret-name>
  5. stringData:
  6. space-webhook-url: https://chat.googleapis.com/v1/spaces/<space_id>/messages?key=<key>&token=<token>
  1. Create a subscription for your space
  1. apiVersion: argoproj.io/v1alpha1
  2. kind: Application
  3. metadata:
  4. annotations:
  5. 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:

  1. template.app-sync-succeeded: |
  2. message: The app {{ .app.metadata.name }} has successfully synced!

A card message can be defined as follows:

  1. template.app-sync-succeeded: |
  2. googlechat:
  3. cards: |
  4. - header:
  5. title: ArgoCD Bot Notification
  6. sections:
  7. - widgets:
  8. - textParagraph:
  9. text: The app {{ .app.metadata.name }} has successfully synced!
  10. - widgets:
  11. - keyValue:
  12. topLabel: Repository
  13. content: {{ call .repo.RepoURLToHTTPS .app.spec.source.repoURL }}
  14. - keyValue:
  15. topLabel: Revision
  16. content: {{ .app.spec.source.targetRevision }}
  17. - keyValue:
  18. topLabel: Author
  19. content: {{ (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:

  1. template.app-sync-succeeded: |
  2. message: The app {{ .app.metadata.name }} has succesfully synced!
  3. googlechat:
  4. threadKey: {{ .app.metadata.name }}