Skip to content

chinaloryu/drone-dingtalk-message

 
 

Repository files navigation

Drone CI DingTalk Message Plugin

Docker Cloud Build Status Go Report Card codecov LICENSE: MIT

just support text, markdown and link type now

Drone CI Plugin Config

0.8.x

pipeline:
  ...
  notification:
    image: lddsb/drone-dingtalk-message
    token: your-group-bot-token
    type: markdown

1.0.x

kind: pipeline
name: default

steps:
...
- name: notification
  image: lddsb/drone-dingtalk-message
  settings:
    token: your-groupbot-token
    type: markdown

Plugin Parameter Reference

token(required)

String. Access token for group bot. (you can get the access token when you add a bot in a group)

type(required)

String. Message type, plan support text, markdown, link and action card, but due to time issue, it's only support markdown and text now, and you can get the best experience by use markdown.

tpl

String. Your custom tpl, it can be a local path or a remote http link.

success_color

String. You can customize the color for the build success message by this option, you should input a hex color, example: 008000.

failure_color

String. You can customize the color for the build success message by this option, you should input a hex color, example: FF0000.

success_pic

String. You can customize the picture for the build success message by this option.

failure_pic

String. You can customize the picture for the build failure message by this option.

tpl_commit_branch_name

String. You can customize the [TPL_COMMIT_BRANCH] by this configuration item.

tpl_repo_short_name

String. You can customize the [TPL_REPO_SHORT_NAME] by this configuration item.

tpl_repo_full_name

String. You can customize the [TPL_REPO_FULL_NAME] by this configuration item.

tpl_build_status_sucdess

String. You can customize the [TPL_BUILD_STATUS] (when status=success) by this configuration item.

tpl_build_status_failure

String. You can customize the [TPL_BUILD_STATUS] (when status=failure) by this configuration item.

TPL

tpl won't work with message type link !!!

That's a good news, we support tpl now.This is a example for markdown message:

# [TPL_REPO_FULL_NAME] build [TPL_BUILD_STATUS], takes [TPL_BUILD_CONSUMING]s
[TPL_COMMIT_MSG]

[TPL_COMMIT_SHA]([TPL_COMMIT_LINK])

[[TPL_AUTHOR_NAME]([TPL_AUTHOR_EMAIL])](mailto:[TPL_AUTHOR_EMAIL])

[Click To The Build Detail Page [TPL_STATUS_EMOTICON)]]([TPL_BUILD_LINK])

You can write your own tpl what you want. The syntax of tpl is very simple, you can fill tpl with preset variables. It's a list of currently supported preset variables:

Variable Value
[TPL_REPO_SHORT_NAME] current repo name(bare name)
[TPL_REPO_FULL_NAME] the full name(with group name) of current repo
[TPL_REPO_GROUP_NAME] the group name of current repo
[TPL_REPO_OWNER_NAME] the owner name of current repo
[TPL_REPO_REMOTE_URL] the remote url of current repo
[TPL_BUILD_STATUS] current build status(e.g., success, failure)
[TPL_BUILD_LINK] current build link
[TPL_BUILD_EVENT] current build event(e.g., push, pull request, etc.)
[TPL_BUILD_CONSUMING] current build consuming, second
[TPL_COMMIT_SHA] current commit sha
[TPL_COMMIT_REF] current commit ref(e.g., refs/heads/master, etc.)
[TPL_COMMIT_LINK] current commit remote url link
[TPL_COMMIT_BRANCH] current branch name(e.g., dev, etc)
[TPL_COMMIT_MSG] current commit message
[TPL_AUTHOR_NAME] current commit author name
[TPL_AUTHOR_EMAIL] current commit author email
[TPL_AUTHOR_USERNAME] current commit author username
[TPL_AUTHOR_AVATAR] current commit author avatar
[TPL_STATUS_PIC] custom pic for build status
[TPL_STATUS_COLOR] custom color for build status
[TPL_STATUS_EMOTICON] custom emoticon for build status

Screen Shot

  • Send Success

send-success

  • Missing Access Token

missing-access-token

  • Missing Message Type Or Not Support Message Type

message-type-error

  • Markdown DingTalk Message(default)

markdown-message-default

  • Markdown DingTalk Message(color and sha link)

markdown-massage-customize

  • Markdown DingTalk Message(color, pic and sha link)

markdown-massage-customize

Development

We use go mod to manage dependencies, so it's easy to build.

  • get this repo
$ git clone https://github.com/lddsb/drone-dingtalk-message.git /path/to/you/want
  • build
$ cd /path/to/you/want && GO111MODULE=on go build .
  • run
$ ./drone-dingtalk-message -h

Todo

  • implement all message type #@20221115
for test

About

A plugins for drone ci to message a group by robot

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Go 94.1%
  • Smarty 2.8%
  • Dockerfile 1.8%
  • Makefile 1.3%