first commit

This commit is contained in:
fredix 2019-06-09 14:49:22 +02:00
parent eae0e1caf4
commit 6721e40017
3 changed files with 35 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
drone-gotify

View file

@ -1,2 +1,9 @@
# drone-gotify
environment variables :
PLUGIN_ENDPOINT=https://gotify.server
PLUGIN_TOKEN=APPLICATION_TOKEN
PLUGIN_TITLE="from drone-gotify"
PLUGIN_MESSAGE="test"
PLUGIN_PRIORITY=5

27
drone-gotify.go Normal file
View file

@ -0,0 +1,27 @@
package main
import (
"net/http"
"net/url"
"os"
"log"
)
// https://gotify.net/docs/more-pushmsg#golang
// https://docs.drone.io/plugins/examples/golang/
func main() {
token := os.Getenv("PLUGIN_TOKEN")
endpoint := os.Getenv("PLUGIN_ENDPOINT")
title := os.Getenv("PLUGIN_TITLE")
message := os.Getenv("PLUGIN_MESSAGE")
priority := os.Getenv("PLUGIN_PRIORITY")
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)
}
}