Compare commits

...

2 Commits

Author SHA1 Message Date
lddsb 9df9c9aa37 add tips title option 2019-11-07 21:40:28 +08:00
lddsb f931e70cc7 compatible full token url as token parameter 2019-09-24 09:26:28 +08:00
6 changed files with 35 additions and 12 deletions
+11 -3
View File
@@ -1,9 +1,17 @@
FROM alpine:latest
FROM golang AS builder
WORKDIR /app
COPY . .
ENV GO111MODULE on
ENV CGO_ENABLED 0
ENV GOOS linux
RUN go build -a -o drone-dingtalk .
FROM alpine:latest
RUN apk update && \
apk add \
ca-certificates && \
rm -rf /var/cache/apk/*
ADD drone-dingtalk-message /bin/
ENTRYPOINT ["/bin/drone-dingtalk-message"]
COPY --from=builder /app/drone-dingtalk /bin/
ENTRYPOINT ["/bin/drone-dingtalk"]
+5 -1
View File
@@ -36,6 +36,10 @@ String. Access token for group bot. (you can get the access token when you add a
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.
`tips_title`
String. You can customize the title for the message tips, just work when message type is markdown.
`message_color`(when `type=markdown`)
Boolean value. This option can change the title and commit message color if turn on.
@@ -113,4 +117,4 @@ cd $GOPATH/src/github.com/lddsb/drone-dingtalk-message && go build .
- run
```shell
./drone-dingtalk-message -h
```
```
+1 -1
View File
@@ -4,6 +4,6 @@ go 1.12
require (
github.com/joho/godotenv v1.3.0
github.com/lddsb/dingtalk-webhook v0.0.0-20190307231412-b4abe34b5fa9
github.com/lddsb/dingtalk-webhook v0.0.1
github.com/urfave/cli v1.20.0
)
+2 -2
View File
@@ -1,6 +1,6 @@
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.0-20190307231412-b4abe34b5fa9 h1:ZeUdCEbcT0+l10jTSyjU9+18ZbDTz6TdkH6yGiCd9dQ=
github.com/lddsb/dingtalk-webhook v0.0.0-20190307231412-b4abe34b5fa9/go.mod h1:5E+/sOBb6m+3ztqnZl4danEY3I5FeIwb12v12s9osbw=
github.com/lddsb/dingtalk-webhook v0.0.1 h1:l4FdTMaRaHnrYfByALukFWK0ru9Rttl0dANg13/SnTI=
github.com/lddsb/dingtalk-webhook v0.0.1/go.mod h1:5E+/sOBb6m+3ztqnZl4danEY3I5FeIwb12v12s9osbw=
github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
+10 -4
View File
@@ -144,6 +144,11 @@ func main() {
Usage: "link sha source page or not",
EnvVar: "PLUGIN_SHA_LINK,PLUGIN_MESSAGE_SHA_LINK",
},
cli.StringFlag{
Name: "config.tips.title",
Usage: "tips title, just work for markdown type message",
EnvVar: "PLUGIN_TIPS_TITLE",
},
}
if err := app.Run(os.Args); nil != err {
@@ -184,10 +189,11 @@ func run(c *cli.Context) {
Config: Config{
AccessToken: c.String("config.token"),
//Lang: c.String("config.lang"),
IsAtALL: c.Bool("config.message.at.all"),
MsgType: c.String("config.message.type"),
Mobiles: c.String("config.message.at.mobiles"),
Debug: c.Bool("config.debug"),
IsAtALL: c.Bool("config.message.at.all"),
MsgType: c.String("config.message.type"),
Mobiles: c.String("config.message.at.mobiles"),
Debug: c.Bool("config.debug"),
TipsTitle: c.String("config.tips.title"),
},
Extra: Extra{
Pic: ExtraPic{
+6 -1
View File
@@ -52,6 +52,7 @@ type (
Mobiles string
Username string
MsgType string
TipsTitle string
}
// MessageConfig `DingTalk message struct`
@@ -108,11 +109,15 @@ func (p *Plugin) Exec() error {
return errors.New("commit sha cannot short than 6")
}
if p.Config.TipsTitle == "" {
p.Config.TipsTitle = "you have a new message"
}
newWebhook := webhook.NewWebHook(p.Config.AccessToken)
mobiles := strings.Split(p.Config.Mobiles, ",")
switch strings.ToLower(p.Config.MsgType) {
case "markdown":
err = newWebhook.SendMarkdownMsg("You have a new message...", p.baseTpl(), p.Config.IsAtALL, mobiles...)
err = newWebhook.SendMarkdownMsg(p.Config.TipsTitle, p.baseTpl(), p.Config.IsAtALL, mobiles...)
case "text":
err = newWebhook.SendTextMsg(p.baseTpl(), p.Config.IsAtALL, mobiles...)
case "link":