Skip to content

Overview

Triggers and templates are configured in the config.yaml field of the argocd-notification-cm ConfigMap:

apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-notifications-cm
data:
  config.yaml: |
    subscriptions:
    # global subscription for all type of notifications
    - recipients:
      - slack:test1
      - webhook:github
    # subscription for on-sync-status-unknown trigger notifications
    - recipients:
      - slack:test2
      - email:test@gmail.com
      trigger: on-sync-status-unknown
    # global subscription restricted to applications with matching labels only
    - recipients:
      - slack:test3
      selector: test=true
    triggers:
      # Enable existing built-in trigger
      - name: on-sync-status-unknown
        enabled: true
      # Define your custom trigger
      - name: my-custom-trigger
        condition: app.status.sync.status == 'Unknown'
        template: my-custom-template
    templates:
      # Add your custom template
      - name: my-custom-template
        title: Hello {{.app.metadata.name}}
        body: |
          Application details: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}.
      # Override one field in built-in template
      - name: on-sync-succeeded
        title: Application {{.app.metadata.name}} sync status is {{.app.status.sync.status}}
        body: "{{call .git.GetCommitMetadata .app.status.sync.revision}}"

Triggers

The trigger defines the condition when the notification should be sent. The definition includes name, condition and notification template reference.

The following trigger sends a notification when application sync status changes to Unknown:

  - name: on-sync-status-unknown
    condition: app.status.sync.status == 'Unknown'
    template: app-sync-status
    enabled: true
  • name - a unique trigger identifier.
  • template - the name of the template that defines the notification content.
  • condition - a predicate expression that returns true if the notification should be sent. The trigger condition evaluation is powered by antonmedv/expr. The condition language syntax is described at Language-Definition.md.
  • enabled - flag that indicates if trigger is enabled or not. By default trigger is enabled.

Templates

The notification template is used to generate the notification content. The template is leveraging html/template golang package and allow to define notification title and body. The template is meant to be reusable and can be referenced by multiple triggers.

The following template is used to notify the user about application sync status.

  - name: app-sync-status
    title: Application {{.app.metadata.name}} sync status is {{.app.status.sync.status}}
    body: |
      Application {{.app.metadata.name}} sync is {{.app.status.sync.status}}.
      Application details: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}.

Each template has access to the app and context fields:

  • app holds the application object.
  • context is user defined string map and might include any string keys and values.