Compare commits

...

14 Commits

Author SHA1 Message Date
dependabot[bot] 4db9815ece build(deps): bump github.com/urfave/cli from 1.22.14 to 1.22.15
Bumps [github.com/urfave/cli](https://github.com/urfave/cli) from 1.22.14 to 1.22.15.
- [Release notes](https://github.com/urfave/cli/releases)
- [Changelog](https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/urfave/cli/compare/v1.22.14...v1.22.15)

---
updated-dependencies:
- dependency-name: github.com/urfave/cli
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-27 07:11:55 +08:00
lddsb eed2f0fae1 fix: Fix release failure caused by deprecated archives->replacements 2024-04-14 07:48:52 +08:00
lddsb ca944a4a26 fix: Fix issues that do not exist in Golang version 1.15.6
Replace specific version numbers with stable versions
2024-04-13 19:28:05 +08:00
lddsb 07310794cb perf: Optimize color setting logic
Allow color code strings to start with #
2024-04-13 18:32:09 +08:00
lddsb a165a28c60 fix: README typo 2024-04-13 18:21:15 +08:00
dependabot[bot] 43222b966a build(deps): bump github.com/urfave/cli from 1.22.5 to 1.22.14
Bumps [github.com/urfave/cli](https://github.com/urfave/cli) from 1.22.5 to 1.22.14.
- [Release notes](https://github.com/urfave/cli/releases)
- [Changelog](https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/urfave/cli/compare/v1.22.5...v1.22.14)

---
updated-dependencies:
- dependency-name: github.com/urfave/cli
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-13 18:09:19 +08:00
dependabot[bot] 530b471503 build(deps): bump github.com/joho/godotenv from 1.4.0 to 1.5.1
Bumps [github.com/joho/godotenv](https://github.com/joho/godotenv) from 1.4.0 to 1.5.1.
- [Release notes](https://github.com/joho/godotenv/releases)
- [Commits](https://github.com/joho/godotenv/compare/v1.4.0...v1.5.1)

---
updated-dependencies:
- dependency-name: github.com/joho/godotenv
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-11 20:31:25 +08:00
internelp 3a0957f479 Use exec instead of Docker for execution 2024-04-11 20:31:13 +08:00
dependabot[bot] c9a57df515 build(deps): bump github.com/joho/godotenv from 1.3.0 to 1.4.0
Bumps [github.com/joho/godotenv](https://github.com/joho/godotenv) from 1.3.0 to 1.4.0.
- [Release notes](https://github.com/joho/godotenv/releases)
- [Commits](https://github.com/joho/godotenv/compare/v1.3.0...v1.4.0)

---
updated-dependencies:
- dependency-name: github.com/joho/godotenv
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-28 09:41:01 +08:00
lddsb d0a4fc64e4 feat: support string as a tpl 2021-08-26 09:29:12 +08:00
lddsb 526b8eec46 docs: update README for at mobiles 2021-07-02 23:13:05 +08:00
lddsb 8729ae05b4 feat: add at mobiles tpl 2021-07-02 23:01:24 +08:00
dependabot[bot] cec9f81f52 build(deps): bump github.com/lddsb/dingtalk-webhook from 0.0.4 to 0.0.5
Bumps [github.com/lddsb/dingtalk-webhook](https://github.com/lddsb/dingtalk-webhook) from 0.0.4 to 0.0.5.
- [Release notes](https://github.com/lddsb/dingtalk-webhook/releases)
- [Commits](https://github.com/lddsb/dingtalk-webhook/compare/v0.0.4...v0.0.5)

---
updated-dependencies:
- dependency-name: github.com/lddsb/dingtalk-webhook
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-02 22:01:57 +08:00
dependabot-preview[bot] 428577470d Upgrade to GitHub-native Dependabot 2021-06-26 23:30:42 +08:00
9 changed files with 128 additions and 44 deletions
+8
View File
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
time: "10:00"
open-pull-requests-limit: 10
+5 -5
View File
@@ -11,15 +11,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: 1.15.6
go-version: stable
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --rm-dist
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.CR_PAT }}
+7 -7
View File
@@ -33,13 +33,13 @@ changelog:
- Merge branch
- go mod tidy
archives:
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
- name_template: >-
{{- .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end -}}
format_overrides:
- goos: windows
format: zip
+27 -3
View File
@@ -19,7 +19,7 @@
`0.8.x`
```yaml
pipeline:
...
#...
notification:
image: lddsb/drone-dingtalk-message
token: your-group-bot-token
@@ -29,7 +29,7 @@ pipeline:
`1.x`
```yaml
steps:
...
#...
- name: notification
image: lddsb/drone-dingtalk-message
settings:
@@ -39,6 +39,25 @@ steps:
debug: true
```
`Use the "exec" type`
```yaml
kind: pipeline
type: exec
steps:
...
- name: notification
environment: # Using environment to pass parameters
PLUGIN_TOKEN:
from_secret: dingtalk_token
PLUGIN_TYPE: markdown
PLUGIN_DEBUG: false
PLUGIN_TPL: /data/drone/dingtalk/tpls/markdown.tpl # The actual location (absolute path) of the tpl.
commands:
- /data/drone/dingtalk/dingtalk-message # Location of the "dingtalk-message" file (absolute path)
```
### Plugin Parameter Reference
`token`(required)
@@ -99,12 +118,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])
@@ -182,7 +206,7 @@ $ cd /path/to/you/want && GO111MODULE=on go build .
$ ./drone-dingtalk-message -h
```
### Todo
### TODO
It's sad, just support `text`, `markdown` and `link` type now.
- implement all message type
- i18N
+26
View File
@@ -40,6 +40,25 @@ steps:
debug: true
```
`命令行版本`
```yaml
kind: pipeline
type: exec
steps:
...
- name: 通知
environment: # 使用 environment 传递参数
PLUGIN_TOKEN:
from_secret: dingtalk_token
PLUGIN_TYPE: markdown
PLUGIN_DEBUG: false
PLUGIN_TPL: /data/drone/dingtalk/tpls/markdown.tpl # tpl 的实际位置(绝对路径)
commands:
- /data/drone/dingtalk/dingtalk-message # dingtalk-message 文件的位置(绝对路径)
```
### 插件参数
`token`(必须)
@@ -101,12 +120,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 +139,8 @@ steps:
[Click To The Build Detail Page [TPL_STATUS_EMOTICON)]]([TPL_BUILD_LINK])
`mobile1``mobile2` 应该为钉钉对应的手机号码,可以放在自己想要放的位置。
你可以写自己喜欢的模版,终于不用再对默认模版发愁啦!并且模版的语法非常简单!比较可惜的是目前支持的变量还比较少,下面是当前支持的变量的列表:
| Variable | Value |
+3 -3
View File
@@ -3,7 +3,7 @@ module github.com/lddsb/drone-dingtalk-message
go 1.12
require (
github.com/joho/godotenv v1.3.0
github.com/lddsb/dingtalk-webhook v0.0.4
github.com/urfave/cli v1.22.5
github.com/joho/godotenv v1.5.1
github.com/lddsb/dingtalk-webhook v0.0.5
github.com/urfave/cli v1.22.15
)
+28 -20
View File
@@ -1,23 +1,31 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
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/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
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=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/urfave/cli v1.22.15 h1:nuqt+pdC/KqswQKhETJjo7pvn/k4xMUxgW6liI7XpnM=
github.com/urfave/cli v1.22.15/go.mod h1:wSan1hmo5zeyLGBjRJbzRTNk8gwoYa2B9n4q9dmRIc0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+13 -6
View File
@@ -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)
@@ -414,13 +415,19 @@ func (p *Plugin) getColor() string {
// success color
colors["success"] = "#008000"
if p.Custom.Color.SuccessColor != "" {
colors["success"] = "#" + p.Custom.Color.SuccessColor
if p.Custom.Color.SuccessColor[0] != '#' {
p.Custom.Color.SuccessColor = "#" + p.Custom.Color.SuccessColor
}
colors["success"] = p.Custom.Color.SuccessColor
}
// failure color
colors["failure"] = "#FF0000"
if p.Custom.Color.FailureColor != "" {
colors["failure"] = "#" + p.Custom.Color.FailureColor
if p.Custom.Color.FailureColor[0] != '#' {
p.Custom.Color.FailureColor = "#" + p.Custom.Color.FailureColor
}
colors["failure"] = p.Custom.Color.FailureColor
}
color, ok := colors[p.Drone.Build.Status]
+11
View File
@@ -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])