github.com/kvattikuti/drone@v0.2.1-0.20140603034306-d400229a327a/pkg/plugin/notify/notification.go (about) 1 package notify 2 3 import ( 4 "github.com/drone/drone/pkg/model" 5 ) 6 7 // Context represents the context of an 8 // in-progress build request. 9 type Context struct { 10 // Global settings 11 Host string 12 13 // User that owns the repository 14 User *model.User 15 16 // Repository being built. 17 Repo *model.Repo 18 19 // Commit being built 20 Commit *model.Commit 21 } 22 23 type Sender interface { 24 Send(context *Context) error 25 } 26 27 // Notification stores the configuration details 28 // for notifying a user, or group of users, 29 // when their Build has completed. 30 type Notification struct { 31 Email *Email `yaml:"email,omitempty"` 32 Webhook *Webhook `yaml:"webhook,omitempty"` 33 Hipchat *Hipchat `yaml:"hipchat,omitempty"` 34 Irc *IRC `yaml:"irc,omitempty"` 35 Slack *Slack `yaml:"slack,omitempty"` 36 } 37 38 func (n *Notification) Send(context *Context) error { 39 // send email notifications 40 if n.Email != nil { 41 n.Email.Send(context) 42 } 43 44 // send email notifications 45 if n.Webhook != nil { 46 n.Webhook.Send(context) 47 } 48 49 // send email notifications 50 if n.Hipchat != nil { 51 n.Hipchat.Send(context) 52 } 53 54 // send irc notifications 55 if n.Irc != nil { 56 n.Irc.Send(context) 57 } 58 59 // send slack notifications 60 if n.Slack != nil { 61 n.Slack.Send(context) 62 } 63 64 return nil 65 }