A plugin for sending messages in WeCom (WeChat Work) groups. Through robots, messages can be pushed to specific groups.
robot: String Required, the WeCom robot Webhook URL or the key parameter from the Webhook URLmsgType: String Optional, message type. text|markdown|image|file|message, default: markdowncontent: String Optional, message content.
Valid when msgType is text or markdown or markdown_v2. Choose either content or fromFile, content takes precedencefromFile: String Optional, relative path to the file containing message content.
Valid when msgType is text or markdown or markdown_v2. Choose either content or fromFile, content takes precedencefilePath: String Optional, relative path to the file to be sent. Size should be less than or equal to 20 MBlayouts: String Optional, message content or path to message content file in JSON format.
Required when msgType is messagechatId: String Optional, WeCom conversation ID, supports multiple IDs separated by |visibleToUser: String Optional, specify group members who can see this message, separated by | or ,postId: String Optional, only effective when chatid specifies one blackboardlastMsg: String Optional, WeCom has a message length limit (2048 bytes),
used to add a line of prompt at the end if exceededattachments: String Optional, JSON string (object format).
Define message additional information. See attachments details belowmentioned_list: String Optional, specify group members to mention, separated by | or ,. Valid when msgType is textskip_on_wip: Boolean Optional, default: true. Whether to skip WIP status PR, true skips, false does not skip.For message length and file size limitations, please refer to WeCom API
Define additional message information, currently only supports button type.
attachments can be passed when msgType is markdown.
callback_id: String Required, callback ID for attachments, WeCom will pass this value in callbacksactions: String Required, array of objects format, attachment actions, maximum 20 actions per attachment.
type: String Required, action type, currently only supports buttonsname: String Required, action name, passed in callbacks, max 64 bytes.
Developers should ensure name uniqueness to distinguish different buttonstext: String Required, text to display, max 128 bytesborder_color: String Optional, button border colortext_color: String Optional, button text colorvalue: String Required, action value, passed in callbacks, max 128 bytesreplace_text: String Required, text to replace after clicking the button, max 128 bytes# .cnb.yml
main:
pull_request:
- stages:
- name: send message
image: tencentcom/wecom-message
settings:
robot: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
msgType: markdown
# Relative path to message content file, choose either fromFile or content, content takes precedence
# fromFile: ./message.txt
content: |
Code review time
${CNB_PULL_REQUEST_TITLE}
[${CNB_EVENT_URL}](${CNB_EVENT_URL})
from ${CNB_BUILD_USER}
main:
push:
- stages:
- name: send message
image: tencentcom/wecom-message
settings:
robot: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
msgType: markdown
# Custom buttons
attachments: |
[
{
"callback_id": "button_two_row",
"actions": [
{
"name": "button_1",
"text": "S",
"type": "button",
"value": "S",
"replace_text": "You have selected S",
"border_color": "2EAB49",
"text_color": "2EAB49"
},
{
"name": "button_2",
"text": "M",
"type": "button",
"value": "M",
"replace_text": "You have selected M",
"border_color": "2EAB49",
"text_color": "2EAB49"
},
{
"name": "button_3",
"text": "L",
"type": "button",
"value": "L",
"replace_text": "You have selected L",
"border_color": "2EAB49",
"text_color": "2EAB49"
},
{
"name": "button_4",
"text": "Uncertain",
"type": "button",
"value": "Uncertain",
"replace_text": "You have selected Uncertain",
"border_color": "2EAB49",
"text_color": "2EAB49"
},
{
"name": "button_5",
"text": "Not participating",
"type": "button",
"value": "Not participating",
"replace_text": "You have selected Not participating",
"border_color": "2EAB49",
"text_color": "2EAB49"
}
]
}
]
main:
push:
- stages:
- name: send message
image: tencentcom/wecom-message
settings:
robot: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
msgType: message
layouts: layouts.json
layouts.json
[
{
"type": "column_layout",
"components": [
{
"type": "plain_text",
"text": "Checkbox",
"style": "title"
},
{
"type": "checkbox",
"key": "checkbox_3",
"options": [
{
"id": "1",
"text": "Option Name 1",
"checked": true
},
{
"id": "2",
"text": "Option Name 2",
"checked": false
}
]
}
]
}
]