Skip to main content
Version: v1.1

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

ParameterTypeDescription
slackObjectOptional, please fulfill its url and message if you want to send Slack messages
slack.urlObjectRequired, the webhook address of Slack, you can choose to fill it in directly or specify it in secret
slack.url.addressStringOptional, directly specify the webhook address of Slack
slack.url.fromSecret.nameStringOptional, specify the webhook address of Slack from secret
slack.url.fromSecret.keyStringOptional, specify the webhook address of Slack from secret, the key of the secret
slack.messageObjectRequired, the Slack messages you want to send, please follow Slack messaging
dingdingObjectOptional, please fulfill its url and message if you want to send DingTalk messages
dingding.urlObjectRequired, the webhook address of DingTalk, you can choose to fill it in directly or specify it in secret
dingding.url.addressStringOptional, directly specify the webhook address of DingTalk
dingding.url.fromSecret.nameStringOptional, specify the webhook address of DingTalk from secret
dingding.url.fromSecret.keyStringOptional, specify the webhook address of DingTalk from secret, the key of the secret
dingding.messageObjectRequired, 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:
- name: app-status
valueFrom: output.status.conditions[0].message + "工作流运行完成"
- name: slack-message
type: webhook-notification
inputs:
- from: app-status
parameterKey: 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.