mirror of
https://framagit.org/fredix/drone-gotify
synced 2026-01-22 18:04:16 +00:00
clean code
This commit is contained in:
parent
1c4dd9fbbb
commit
36681cc50d
3 changed files with 25 additions and 29 deletions
27
README.md
27
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 ]
|
||||
```
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue