Commit 36681cc5 authored by fredix's avatar fredix
Browse files

clean code

parent 1c4dd9fb
......@@ -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
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"
......
......@@ -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
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment