Configuring notifications

This page describes how to configure piped to send notifications to external services.

PipeCD events (deployment triggered, planned, completed, analysis result, piped started…) can be sent to external services like Slack or a Webhook service. While forwarding those events to a chat service helps developers have a quick and convenient way to know the deployment’s current status, forwarding to a Webhook service may be useful for triggering other related tasks like CI jobs.

PipeCD events are emitted and sent by the piped component. So all the needed configurations can be specified in the piped configuration file. Notification configuration including:

  • a list of Routes which used to match events and decide where the event should be sent to
  • a list of Receivers which used to know how to send events to the external service

Notification Route matches events based on their metadata like name, group, app, labels. Below is the list of supporting event names and their groups.

EventGroupSupportedDescription
DEPLOYMENT_TRIGGEREDDEPLOYMENT

DEPLOYMENT_PLANNEDDEPLOYMENT

DEPLOYMENT_STARTEDDEPLOYMENT

DEPLOYMENT_APPROVEDDEPLOYMENT

DEPLOYMENT_WAIT_APPROVALDEPLOYMENT

DEPLOYMENT_ROLLING_BACKDEPLOYMENT

PipeCD sends a notification when a deployment is completed, while it does not send a notification when a deployment status changes to DEPLOYMENT_ROLLING_BACK because it is not a completion status. See #4547
DEPLOYMENT_SUCCEEDEDDEPLOYMENT

DEPLOYMENT_FAILEDDEPLOYMENT

DEPLOYMENT_CANCELLEDDEPLOYMENT

DEPLOYMENT_TRIGGER_FAILEDDEPLOYMENT

APPLICATION_SYNCEDAPPLICATION_SYNC

APPLICATION_OUT_OF_SYNCAPPLICATION_SYNC

APPLICATION_HEALTHYAPPLICATION_HEALTH

APPLICATION_UNHEALTHYAPPLICATION_HEALTH

PIPED_STARTEDPIPED

PIPED_STOPPEDPIPED

Sending notifications to Slack

apiVersion: pipecd.dev/v1beta1
kind: Piped
spec:
  notifications:
    routes:
      # Sending all event which contains labels `env: dev` to dev-slack-channel.
      - name: dev-slack
        labels:
          env: dev
        receiver: dev-slack-channel
      # Only sending deployment started and completed events which contains
      # labels `env: prod` and `team: pipecd` to prod-slack-channel.
      - name: prod-slack
        events:
          - DEPLOYMENT_TRIGGERED
          - DEPLOYMENT_SUCCEEDED
        labels:
          env: prod
          team: pipecd
        receiver: prod-slack-channel
      - name: integration-slack
        receiver: integration-slack-api
    receivers:
      - name: dev-slack-channel
        slack:
          hookURL: https://slack.com/dev
      - name: prod-slack-channel
        slack:
          hookURL: https://slack.com/prod
      - name: integration-slack-api
        slack:
          oauthTokenData: "token"
          channelID: "testid"
      - name: hookurl-with-mentioned-accounts
        slack:
          hookURL: https://slack.com/dev,
          mentionedAccounts:
            - '@user1'
            - 'user2'
      - name: integration-slack-api-with-mentioned-accounts
        slack:
          oauthTokenData: token
          channelID: testid
          mentionedAccounts:
            - '@user1'
            - 'user2'
      - name: integration-slack-api-with-oauthTokenData-and-mentioned-groups
        slack:
          oauthTokenData: token
          channelID: testid
          mentionedGroups:
            - 'group1'
            - '<!subteam^group2>'
      - name: integration-slack-api-with-oauthTokenData-and-mentioned-both-accounts-and-groups
        slack:
          oauthTokenData: token
          channelID: testid
          mentionedAccounts:
            - 'user1'
            - '@user2'
          mentionedGroups:
            - 'groupID1'
            - '<!subteam^groupID2>'

Deployment was triggered, planned and completed successfully

A piped has been started

For detailed configuration, please check the configuration reference for Notifications section.

Sending notifications to external services via webhook

apiVersion: pipecd.dev/v1beta1
kind: Piped
spec:
  notifications:
    routes:
      # Sending all events an external service.
      - name: all-events-to-a-external-service
        receiver: a-webhook-service
    receivers:
      - name: a-webhook-service
        webhook:
          url: {WEBHOOK_SERVICE_URL}
          signatureValue: {RANDOM_SIGNATURE_STRING}

For detailed configuration, please check the configuration reference for NotificationReceiverWebhook section.