kubevela.github.io/docs/end-user/workflow/webhook-notification.md

3.9 KiB

title
Webhook Notification

If we want to be notified before or after deploying an application, KubeVela provides integration with notification webhooks, allowing users to send notifications to DingTalk or Slack.

In this guide, you will learn how to send notifications via webhook-notification in workflow.

Make sure the version of KubeVela is >=v1.1.6.

Parameters

Parameter Type Description
slack Object Optional, please fulfill its url and message if you want to send Slack messages
slack.url Object Required, the webhook address of Slack, you can choose to fill it in directly or specify it in secret
slack.url.address String Optional, directly specify the webhook address of Slack
slack.url.fromSecret.name String Optional, specify the webhook address of Slack from secret
slack.url.fromSecret.key String Optional, specify the webhook address of Slack from secret, the key of the secret
slack.message Object Required, the Slack messages you want to send, please follow Slack messaging
dingding Object Optional, please fulfill its url and message if you want to send DingTalk messages
dingding.url Object Required, the webhook address of DingTalk, you can choose to fill it in directly or specify it in secret
dingding.url.address String Optional, directly specify the webhook address of DingTalk
dingding.url.fromSecret.name String Optional, specify the webhook address of DingTalk from secret
dingding.url.fromSecret.key String Optional, specify the webhook address of DingTalk from secret, the key of the secret
dingding.message Object Required, the DingTalk messages you want to send, please follow DingTalk messaging

How to use

Apply the following Application with workflow step type of webhook-notification:

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: first-vela-workflow
  namespace: default
spec:
  components:
  - name: express-server
    type: webservice
    properties:
      image: crccheck/hello-world
      port: 8000
    traits:
    - type: ingress
      properties:
        domain: testsvc.example.com
        http:
          /: 8000
  workflow:
    steps:
      - name: dingtalk-message
        # specify the workflow step type
        type: webhook-notification
        properties:
          dingding:
            # the DingTalk webhook address, please refer to: https://developers.dingtalk.com/document/robots/custom-robot-access
            url:
              address: <your dingding url>
            # specify the message details
            message:
              msgtype: text
              text:
                content: Workflow starting...
      - name: application
        type: apply-component
        properties:
          component: express-server
        outputs:
          - from: app-status
            valueFrom: output.status.conditions[0].message + "工作流运行完成"
      - name: slack-message
        type: webhook-notification
        inputs:
          - name: app-status
            parameterKey: properties.slack.message.text
        properties:
          slack:
            # the Slack webhook address, please refer to: https://api.slack.com/messaging/webhooks
            url:
              fromSecret:
                name: <the secret name that stores your slack url>
                key: <the secret key that stores your slack url>
            # specify the message details, will be filled by the input value
            # message:
            #   text: condition message + Workflow ended.

Expected outcome

we can see that before and after the deployment of the application, the messages can be seen in the corresponding group chat.

With webhook-notification, we can integrate with webhook notifier easily.