mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-27 20:31:10 +00:00
75 lines
1.5 KiB
Go
75 lines
1.5 KiB
Go
package notify
|
|
|
|
import (
|
|
"log"
|
|
|
|
"github.com/drone/drone/plugin/notify/email"
|
|
"github.com/drone/drone/plugin/notify/github"
|
|
"github.com/drone/drone/shared/model"
|
|
)
|
|
|
|
type Sender interface {
|
|
Send(context *model.Request) error
|
|
}
|
|
|
|
// Notification stores the configuration details
|
|
// for notifying a user, or group of users,
|
|
// when their Build has completed.
|
|
type Notification struct {
|
|
Email *email.Email `yaml:"email,omitempty"`
|
|
Webhook *Webhook `yaml:"webhook,omitempty"`
|
|
Hipchat *Hipchat `yaml:"hipchat,omitempty"`
|
|
Irc *IRC `yaml:"irc,omitempty"`
|
|
Slack *Slack `yaml:"slack,omitempty"`
|
|
|
|
GitHub github.GitHub `yaml:"github_status"`
|
|
}
|
|
|
|
func (n *Notification) Send(context *model.Request) error {
|
|
// send email notifications
|
|
if n.Email != nil {
|
|
err := n.Email.Send(context)
|
|
if err != nil {
|
|
log.Println(err)
|
|
}
|
|
}
|
|
|
|
// send webhook notifications
|
|
if n.Webhook != nil {
|
|
err := n.Webhook.Send(context)
|
|
if err != nil {
|
|
log.Println(err)
|
|
}
|
|
}
|
|
|
|
// send hipchat notifications
|
|
if n.Hipchat != nil {
|
|
err := n.Hipchat.Send(context)
|
|
if err != nil {
|
|
log.Println(err)
|
|
}
|
|
}
|
|
|
|
// send irc notifications
|
|
if n.Irc != nil {
|
|
err := n.Irc.Send(context)
|
|
if err != nil {
|
|
log.Println(err)
|
|
}
|
|
}
|
|
|
|
// send slack notifications
|
|
if n.Slack != nil {
|
|
err := n.Slack.Send(context)
|
|
if err != nil {
|
|
log.Println(err)
|
|
}
|
|
}
|
|
|
|
// send email notifications
|
|
if err := n.GitHub.Send(context); err != nil {
|
|
log.Println(err)
|
|
}
|
|
|
|
return nil
|
|
}
|