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