mirror of
https://github.com/lddsb/drone-dingtalk-message.git
synced 2026-06-14 22:12:27 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4db9815ece | |||
| eed2f0fae1 | |||
| ca944a4a26 | |||
| 07310794cb | |||
| a165a28c60 | |||
| 43222b966a | |||
| 530b471503 | |||
| 3a0957f479 | |||
| c9a57df515 | |||
| d0a4fc64e4 |
@@ -11,15 +11,15 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: 1.15.6
|
go-version: stable
|
||||||
- name: Run GoReleaser
|
- name: Run GoReleaser
|
||||||
uses: goreleaser/goreleaser-action@v2
|
uses: goreleaser/goreleaser-action@v5
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
args: release --rm-dist
|
args: release --clean
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.CR_PAT }}
|
GITHUB_TOKEN: ${{ secrets.CR_PAT }}
|
||||||
|
|||||||
+7
-7
@@ -33,13 +33,13 @@ changelog:
|
|||||||
- Merge branch
|
- Merge branch
|
||||||
- go mod tidy
|
- go mod tidy
|
||||||
archives:
|
archives:
|
||||||
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
|
- name_template: >-
|
||||||
replacements:
|
{{- .ProjectName }}_
|
||||||
darwin: Darwin
|
{{- title .Os }}_
|
||||||
linux: Linux
|
{{- if eq .Arch "amd64" }}x86_64
|
||||||
windows: Windows
|
{{- else if eq .Arch "386" }}i386
|
||||||
386: i386
|
{{- else }}{{ .Arch }}{{ end }}
|
||||||
amd64: x86_64
|
{{- if .Arm }}v{{ .Arm }}{{ end -}}
|
||||||
format_overrides:
|
format_overrides:
|
||||||
- goos: windows
|
- goos: windows
|
||||||
format: zip
|
format: zip
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
`0.8.x`
|
`0.8.x`
|
||||||
```yaml
|
```yaml
|
||||||
pipeline:
|
pipeline:
|
||||||
...
|
#...
|
||||||
notification:
|
notification:
|
||||||
image: lddsb/drone-dingtalk-message
|
image: lddsb/drone-dingtalk-message
|
||||||
token: your-group-bot-token
|
token: your-group-bot-token
|
||||||
@@ -29,7 +29,7 @@ pipeline:
|
|||||||
`1.x`
|
`1.x`
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
...
|
#...
|
||||||
- name: notification
|
- name: notification
|
||||||
image: lddsb/drone-dingtalk-message
|
image: lddsb/drone-dingtalk-message
|
||||||
settings:
|
settings:
|
||||||
@@ -39,6 +39,25 @@ steps:
|
|||||||
debug: true
|
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
|
### Plugin Parameter Reference
|
||||||
`token`(required)
|
`token`(required)
|
||||||
|
|
||||||
@@ -187,7 +206,7 @@ $ cd /path/to/you/want && GO111MODULE=on go build .
|
|||||||
$ ./drone-dingtalk-message -h
|
$ ./drone-dingtalk-message -h
|
||||||
```
|
```
|
||||||
|
|
||||||
### Todo
|
### TODO
|
||||||
It's sad, just support `text`, `markdown` and `link` type now.
|
It's sad, just support `text`, `markdown` and `link` type now.
|
||||||
- implement all message type
|
- implement all message type
|
||||||
- i18N
|
- i18N
|
||||||
|
|||||||
@@ -40,6 +40,25 @@ steps:
|
|||||||
debug: true
|
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`(必须)
|
`token`(必须)
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ module github.com/lddsb/drone-dingtalk-message
|
|||||||
go 1.12
|
go 1.12
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/joho/godotenv v1.3.0
|
github.com/joho/godotenv v1.5.1
|
||||||
github.com/lddsb/dingtalk-webhook v0.0.5
|
github.com/lddsb/dingtalk-webhook v0.0.5
|
||||||
github.com/urfave/cli v1.22.5
|
github.com/urfave/cli v1.22.15
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,17 +1,31 @@
|
|||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
|
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||||
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
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 h1:EOSXvcpN4IC7fXSAheI3OLJwwOGEPlGDV7xje1fQuJo=
|
||||||
github.com/lddsb/dingtalk-webhook v0.0.5/go.mod h1:dwNU75Sog87wJXAFcY5mDFM7eW4hIdX7bNemrN92pH0=
|
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 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
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.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU=
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
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/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=
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ type (
|
|||||||
RemoteURL string // repo remote url
|
RemoteURL string // repo remote url
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build build info
|
// Build info
|
||||||
Build struct {
|
Build struct {
|
||||||
Status string // providers the current build status
|
Status string // providers the current build status
|
||||||
Link string // providers the current build link
|
Link string // providers the current build link
|
||||||
@@ -34,7 +34,7 @@ type (
|
|||||||
FinishedAt uint64 // build finish at ( unix timestamp )
|
FinishedAt uint64 // build finish at ( unix timestamp )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commit commit info
|
// Commit info
|
||||||
Commit struct {
|
Commit struct {
|
||||||
Branch string // providers the branch for the current commit
|
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)
|
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
|
Consuming Consuming
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tpl TPL base
|
// Tpl base
|
||||||
Tpl struct {
|
Tpl struct {
|
||||||
Repo TplRepo
|
Repo TplRepo
|
||||||
Commit TplCommit
|
Commit TplCommit
|
||||||
@@ -255,7 +255,8 @@ func (p *Plugin) getTpl() (tpl string, err error) {
|
|||||||
tpl = string(body)
|
tpl = string(body)
|
||||||
} else {
|
} else {
|
||||||
if !fileExists(p.Custom.Tpl) {
|
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)
|
tplStr, err := ioutil.ReadFile(p.Custom.Tpl)
|
||||||
@@ -414,13 +415,19 @@ func (p *Plugin) getColor() string {
|
|||||||
// success color
|
// success color
|
||||||
colors["success"] = "#008000"
|
colors["success"] = "#008000"
|
||||||
if p.Custom.Color.SuccessColor != "" {
|
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
|
// failure color
|
||||||
colors["failure"] = "#FF0000"
|
colors["failure"] = "#FF0000"
|
||||||
if p.Custom.Color.FailureColor != "" {
|
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]
|
color, ok := colors[p.Drone.Build.Status]
|
||||||
|
|||||||
Reference in New Issue
Block a user