woodpecker-email/main.go

53 lines
742 B
Go
Raw Normal View History

package main
import (
2015-11-11 02:44:23 +01:00
"fmt"
"os"
"github.com/drone/drone-go/drone"
"github.com/drone/drone-go/plugin"
)
var (
buildDate string
)
func main() {
fmt.Printf("Drone Email Plugin built at %s\n", buildDate)
system := drone.System{}
repo := drone.Repo{}
build := drone.Build{}
vargs := Params{}
plugin.Param("system", &system)
plugin.Param("repo", &repo)
plugin.Param("build", &build)
plugin.Param("vargs", &vargs)
plugin.MustParse()
2015-11-11 02:44:23 +01:00
if len(vargs.Recipients) == 0 {
vargs.Recipients = []string{
2015-11-11 02:44:23 +01:00
build.Email,
}
}
if vargs.Port == 0 {
vargs.Port = 587
2015-11-11 02:44:23 +01:00
}
err := Send(&Context{
2015-11-11 02:44:23 +01:00
System: system,
Repo: repo,
Build: build,
Vargs: vargs,
})
if err != nil {
2015-11-11 02:44:23 +01:00
fmt.Println(err)
os.Exit(1)
return
}
}