mirror of
https://framagit.org/fredix/drone-gotify
synced 2026-01-22 18:04:16 +00:00
first commit
This commit is contained in:
parent
eae0e1caf4
commit
6721e40017
3 changed files with 35 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
drone-gotify
|
||||
|
|
@ -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
27
drone-gotify.go
Normal 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)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue