diff --git a/README.md b/README.md index 552fa9d..4449782 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,31 @@ https://docs.drone.io/plugins/examples/golang/ ``` PLUGIN_GOTIFY_ENDPOINT="https://gotify.server.tld" -PLUGIN_GOTIFY_TOKEN="APPLICATION_TOKEN" +PLUGIN_GOTIFY_TOKEN="GOTIFY_APPLICATION_TOKEN" PLUGIN_GOTIFY_TITLE="from drone-gotify" -PLUGIN_GOTIFY_MESSAGE="test" +PLUGIN_MESSAGE="test" PLUGIN_GOTIFY_PRIORITY="5" ``` +Example in a .drone.yml + +``` +- name: gotify + image: fredix/arm64v8-alpine-drone-gotify + settings: + gotifytoken: + from_secret: plugin_gotifytoken + gotifyendpoint: + from_secret: plugin_gotifyendpoint + gotifytitle: + from_secret: plugin_gotifytitle + gotifypriority: + from_secret: plugin_gotifypriority + message: > + {{#success build.status}} + build {{build.number}} succeeded on {{repo.name}}. Good job {{build.author}} {{build.link}} + {{else}} + build {{build.number}} failed on {{repo.name}}. Fix me please {{build.author}} {{build.link}} + {{/success}} + when: + status: [ success, failure ] +``` \ No newline at end of file diff --git a/drone-gotify.go b/drone-gotify.go index 2a70478..50f696b 100644 --- a/drone-gotify.go +++ b/drone-gotify.go @@ -1,9 +1,6 @@ package main import ( - //"log" - //"net/http" - //"net/url" "fmt" "os" @@ -19,22 +16,6 @@ var ( func main() { - /* - token := os.Getenv("PLUGIN_GOTIFYTOKEN") - endpoint := os.Getenv("PLUGIN_GOTIFYENDPOINT") - title := os.Getenv("PLUGIN_GOTIFYTITLE") - message := os.Getenv("PLUGIN_MESSAGE") - priority := os.Getenv("PLUGIN_GOTIFYPRIORITY") - - resp, err := http.PostForm(endpoint+"/message?token="+token, url.Values{"message": {message}, "title": {title}, "priority": {priority}}) - if resp != nil { - resp.Body.Close() - } - if err != nil { - log.Fatalln(err) - } - */ - app := cli.NewApp() app.Name = "gotify plugin" app.Usage = "gotify plugin" diff --git a/plugin.go b/plugin.go index 9eb5db7..00464cd 100644 --- a/plugin.go +++ b/plugin.go @@ -61,18 +61,10 @@ func (p Plugin) Exec() error { text = txt } - //client := google_chat.NewClient(p.Config.Webhook, p.Config.Key, p.Config.Token, p.Config.ConversationKey) - //return client.SendMessage(&google_chat.Message{text}) - resp, err := http.PostForm(p.Config.Endpoint+"/message?token="+p.Config.Token, url.Values{"message": {text}, "title": {p.Config.Title}, "priority": {p.Config.Priority}}) if resp != nil { resp.Body.Close() } - /* - if err != nil { - log.Fatalln(err) - } - */ return err }