mirror of
https://github.com/lddsb/drone-dingtalk-message.git
synced 2026-06-13 10:41:36 +08:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d0a4fc64e4 | |||
| 526b8eec46 | |||
| 8729ae05b4 | |||
| cec9f81f52 | |||
| 428577470d |
@@ -0,0 +1,8 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: gomod
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
time: "10:00"
|
||||
open-pull-requests-limit: 10
|
||||
@@ -99,12 +99,17 @@ String. You can customize the [TPL_BUILD_STATUS] (when status=`success`) by this
|
||||
|
||||
String. You can customize the [TPL_BUILD_STATUS] (when status=`failure`) by this configuration item.
|
||||
|
||||
`msg_at_mobiles`
|
||||
|
||||
String. You want at's phone number in the group, if you need at multi phone numbers, you can use `,` to separate. (if you use markdown type, you need define the at content in your tpl file)
|
||||
|
||||
### TPL
|
||||
> `tpl` won't work with message type `link` !!!
|
||||
|
||||
That's a good news, we support `tpl` now.This is an example for `markdown` message:
|
||||
|
||||
# [TPL_REPO_FULL_NAME] build [TPL_BUILD_STATUS], takes [TPL_BUILD_CONSUMING]s
|
||||
@mobile1 @mobile2
|
||||
[TPL_COMMIT_MSG]
|
||||
|
||||
[TPL_COMMIT_SHA]([TPL_COMMIT_LINK])
|
||||
|
||||
@@ -101,12 +101,17 @@ steps:
|
||||
|
||||
你可以通过该字段自定义运行失败状态的值,可以在模版中通过[TPL_BUILD_STATUS]来使用该值。(仅当前方`step`运行结果为失败时该值会生效)
|
||||
|
||||
`msg_at_mobiles`
|
||||
|
||||
你需要@的群成员的手机号,多个时用英文逗号(`,`)分隔。如过你使用的是 `markdown` 类型的消息,则需要在 `tpl` 文件中加入 `@手机号` 的内容。
|
||||
|
||||
### 模版
|
||||
> `tpl` 对 `link` 类型的消息并不支持 !!!
|
||||
|
||||
感天动地,我们终于支持自定义模版了!下面是一个`markdown`的自定义模版例子:
|
||||
|
||||
# [TPL_REPO_FULL_NAME] build [TPL_BUILD_STATUS], takes [TPL_BUILD_CONSUMING]s
|
||||
@mobile1 @mobile2
|
||||
[TPL_COMMIT_MSG]
|
||||
|
||||
[TPL_COMMIT_SHA]([TPL_COMMIT_LINK])
|
||||
@@ -115,6 +120,8 @@ steps:
|
||||
|
||||
[Click To The Build Detail Page [TPL_STATUS_EMOTICON)]]([TPL_BUILD_LINK])
|
||||
|
||||
`mobile1` 和 `mobile2` 应该为钉钉对应的手机号码,可以放在自己想要放的位置。
|
||||
|
||||
你可以写自己喜欢的模版,终于不用再对默认模版发愁啦!并且模版的语法非常简单!比较可惜的是目前支持的变量还比较少,下面是当前支持的变量的列表:
|
||||
|
||||
| Variable | Value |
|
||||
|
||||
@@ -4,6 +4,6 @@ go 1.12
|
||||
|
||||
require (
|
||||
github.com/joho/godotenv v1.3.0
|
||||
github.com/lddsb/dingtalk-webhook v0.0.4
|
||||
github.com/lddsb/dingtalk-webhook v0.0.5
|
||||
github.com/urfave/cli v1.22.5
|
||||
)
|
||||
|
||||
@@ -3,20 +3,14 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSY
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||
github.com/lddsb/dingtalk-webhook v0.0.4 h1:gAJFy66L2gZ5j6kDrHRoz/zQFaNamcObtetNonq76RA=
|
||||
github.com/lddsb/dingtalk-webhook v0.0.4/go.mod h1:dwNU75Sog87wJXAFcY5mDFM7eW4hIdX7bNemrN92pH0=
|
||||
github.com/lddsb/dingtalk-webhook v0.0.5 h1:EOSXvcpN4IC7fXSAheI3OLJwwOGEPlGDV7xje1fQuJo=
|
||||
github.com/lddsb/dingtalk-webhook v0.0.5/go.mod h1:dwNU75Sog87wJXAFcY5mDFM7eW4hIdX7bNemrN92pH0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo=
|
||||
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/urfave/cli v1.22.3 h1:FpNT6zq26xNpHZy08emi755QwzLPs6Pukqjlc7RfOMU=
|
||||
github.com/urfave/cli v1.22.3/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/urfave/cli v1.22.4 h1:u7tSpNPPswAFymm8IehJhy4uJMlUuU/GmqSkvJ1InXA=
|
||||
github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU=
|
||||
github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
||||
@@ -25,7 +25,7 @@ type (
|
||||
RemoteURL string // repo remote url
|
||||
}
|
||||
|
||||
// Build build info
|
||||
// Build info
|
||||
Build struct {
|
||||
Status string // providers the current build status
|
||||
Link string // providers the current build link
|
||||
@@ -34,7 +34,7 @@ type (
|
||||
FinishedAt uint64 // build finish at ( unix timestamp )
|
||||
}
|
||||
|
||||
// Commit commit info
|
||||
// Commit info
|
||||
Commit struct {
|
||||
Branch string // providers the branch for the current commit
|
||||
Link string // providers the http link to the current commit in the remote source code management system(e.g.GitHub)
|
||||
@@ -120,7 +120,7 @@ type (
|
||||
Consuming Consuming
|
||||
}
|
||||
|
||||
// Tpl TPL base
|
||||
// Tpl base
|
||||
Tpl struct {
|
||||
Repo TplRepo
|
||||
Commit TplCommit
|
||||
@@ -255,7 +255,8 @@ func (p *Plugin) getTpl() (tpl string, err error) {
|
||||
tpl = string(body)
|
||||
} else {
|
||||
if !fileExists(p.Custom.Tpl) {
|
||||
return "", errors.New("tpl file not exists")
|
||||
// it must be a tpl stream
|
||||
return p.Custom.Tpl, nil
|
||||
}
|
||||
|
||||
tplStr, err := ioutil.ReadFile(p.Custom.Tpl)
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
### [TPL_REPO_SHORT_NAME] build [TPL_BUILD_STATUS] (`takes [TPL_BUILD_CONSUMING]s`)
|
||||
|
||||
@mobile1 @mobile2
|
||||
|
||||
Message: [TPL_COMMIT_MSG]
|
||||
|
||||
Detail: [[TPL_COMMIT_SHA]]([TPL_COMMIT_LINK])
|
||||
|
||||
Author: [[TPL_AUTHOR_NAME]([TPL_AUTHOR_EMAIL])](mailto:[TPL_AUTHOR_EMAIL])
|
||||
|
||||
[Click To The Build Detail Page [TPL_STATUS_EMOTICON]]([TPL_BUILD_LINK])
|
||||
Reference in New Issue
Block a user