Compare commits

...

8 Commits

Author SHA1 Message Date
Bo-Yi Wu e3fc3f805d docs: update docs 2019-12-07 13:26:50 +08:00
Bo-Yi Wu 44ac6f43de fix: testing 2019-12-07 13:03:59 +08:00
Bo-Yi Wu 5ac85a3412 chore: update socks5 message 2019-12-07 13:00:35 +08:00
Bo-Yi Wu 79e531f648 chore: support github parameter 2019-12-07 12:39:27 +08:00
icecream78 abba2cb37d Add socks5 proxy to plugin (#87) 2019-12-07 11:29:47 +08:00
Bo-Yi Wu 7f8bd6ba04 chore: replace ADD with COPY 2019-11-23 21:51:46 +08:00
Bo-Yi Wu 0dc176a2ac docs: update badge 2019-11-23 21:50:20 +08:00
Bo-Yi Wu 2af2c10e0e chore: update appveyor for windows build 2019-11-23 21:48:06 +08:00
10 changed files with 78 additions and 8 deletions
+2
View File
@@ -10,6 +10,7 @@ environment:
secure: em/TNLUXxG19O/HvbvfJuQ==
docker_password:
secure: Yo9FJJqihaNz5q8T4Jz8tQ==
GO111MODULE: on
branches:
only:
@@ -23,6 +24,7 @@ install:
build_script:
- ps: |
go mod download
if ( $env:APPVEYOR_REPO_TAG -eq 'false' ) {
$version = $env:APPVEYOR_REPO_COMMIT
} else {
+14 -1
View File
@@ -175,7 +175,8 @@ Example configuration with a generic message template loaded from file, with add
```
Where `message_file.tpl` is:
```
```bash
Build finished for *{{tpl.app}}* - *{{tpl.env}}*
{{#success build.status}}
@@ -185,6 +186,18 @@ Build finished for *{{tpl.app}}* - *{{tpl.env}}*
{{/success}}
```
Example configuration with a custom socks5 URL:
```diff
- name: send telegram notification
image: appleboy/drone-telegram
settings:
token: xxxxxxxxxx
to: telegram_user_id
message: send message using custom socks5 URL
+ socks5: socks5://67.204.21.1:64312
```
## Parameter Reference
token
+1 -1
View File
@@ -4,7 +4,7 @@
[![GoDoc](https://godoc.org/github.com/appleboy/drone-telegram?status.svg)](https://godoc.org/github.com/appleboy/drone-telegram)
[![Build Status](https://cloud.drone.io/api/badges/appleboy/drone-telegram/status.svg)](https://cloud.drone.io/appleboy/drone-telegram)
[![Build status](https://ci.appveyor.com/api/projects/status/aexij85gjg3dsesl?svg=true)](https://ci.appveyor.com/project/appleboy/drone-telegram)
[![Build status](https://ci.appveyor.com/api/projects/status/cm4l9udn8ywkif42?svg=true)](https://ci.appveyor.com/project/appleboy/drone-telegram-cd47y)
[![codecov](https://codecov.io/gh/appleboy/drone-telegram/branch/master/graph/badge.svg)](https://codecov.io/gh/appleboy/drone-telegram)
[![Go Report Card](https://goreportcard.com/badge/github.com/appleboy/drone-telegram)](https://goreportcard.com/report/github.com/appleboy/drone-telegram)
[![Docker Pulls](https://img.shields.io/docker/pulls/appleboy/drone-telegram.svg)](https://hub.docker.com/r/appleboy/drone-telegram/)
+1 -1
View File
@@ -5,6 +5,6 @@ LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
org.label-schema.vendor="Bo-Yi Wu" \
org.label-schema.schema-version="1.0"
ADD release/linux/amd64/drone-telegram /bin/
COPY release/linux/amd64/drone-telegram /bin/
ENTRYPOINT ["/bin/drone-telegram"]
+1 -1
View File
@@ -5,6 +5,6 @@ LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
org.label-schema.vendor="Bo-Yi Wu" \
org.label-schema.schema-version="1.0"
ADD release/linux/arm/drone-telegram /bin/
COPY release/linux/arm/drone-telegram /bin/
ENTRYPOINT ["/bin/drone-telegram"]
+1 -1
View File
@@ -5,6 +5,6 @@ LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
org.label-schema.vendor="Bo-Yi Wu" \
org.label-schema.schema-version="1.0"
ADD release/linux/arm64/drone-telegram /bin/
COPY release/linux/arm64/drone-telegram /bin/
ENTRYPOINT ["/bin/drone-telegram"]
+2 -1
View File
@@ -5,5 +5,6 @@ LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
org.label-schema.vendor="Bo-Yi Wu" \
org.label-schema.schema-version="1.0"
ADD release/drone-telegram.exe /drone-telegram.exe
COPY release/drone-telegram.exe /drone-telegram.exe
ENTRYPOINT [ "\\drone-telegram.exe" ]
+6
View File
@@ -245,6 +245,11 @@ func main() {
Usage: "Provides the target deployment environment for the running build. This value is only available to promotion and rollback pipelines.",
EnvVar: "DRONE_DEPLOY_TO",
},
cli.StringFlag{
Name: "socks5",
Usage: "Socks5 proxy URL",
EnvVar: "PLUGIN_SOCKS5,SOCKS5,INPUT_SOCKS5",
},
}
if err := app.Run(os.Args); err != nil {
@@ -310,6 +315,7 @@ func run(c *cli.Context) error {
Venue: c.StringSlice("venue"),
Format: c.String("format"),
GitHub: c.Bool("github"),
Socks5: c.String("socks5"),
},
}
+17 -2
View File
@@ -8,6 +8,8 @@ import (
"html"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"path/filepath"
"strconv"
@@ -83,6 +85,7 @@ type (
Venue []string
Format string
GitHub bool
Socks5 string
}
// Plugin values.
@@ -273,9 +276,21 @@ func (p Plugin) Exec() (err error) {
}
}
var proxyURL *url.URL
if proxyURL, err = url.Parse(p.Config.Socks5); err != nil {
return fmt.Errorf("unable to unmarshall socks5 proxy url from string '%s': %v", p.Config.Socks5, err)
}
var bot *tgbotapi.BotAPI
if bot, err = tgbotapi.NewBotAPI(p.Config.Token); err != nil {
return
if len(p.Config.Socks5) > 0 {
proxyClient := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}}
bot, err = tgbotapi.NewBotAPIWithClient(p.Config.Token, proxyClient)
} else {
bot, err = tgbotapi.NewBotAPI(p.Config.Token)
}
if err != nil {
return err
}
bot.Debug = p.Config.Debug
+33
View File
@@ -385,3 +385,36 @@ func TestTemplateVars(t *testing.T) {
err := plugin.Exec()
assert.Nil(t, err)
}
func TestProxySendMessage(t *testing.T) {
plugin := Plugin{
Repo: Repo{
Name: "go-hello",
Namespace: "appleboy",
},
Commit: Commit{
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
Author: "Bo-Yi Wu",
Branch: "master",
Message: "start use proxy",
Email: "test@gmail.com",
},
Build: Build{
Tag: "1.0.0",
Number: 101,
Status: "success",
Link: "https://github.com/appleboy/go-hello",
},
Config: Config{
Token: os.Getenv("TELEGRAM_TOKEN"),
To: []string{os.Getenv("TELEGRAM_TO")},
Message: []string{"Send message from socks5 proxy URL."},
Debug: false,
Socks5: os.Getenv("SOCKS5"),
},
}
err := plugin.Exec()
assert.Nil(t, err)
}