github.com/unclejack/drone@v0.2.1-0.20140918182345-831b034aa33b/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 Flowdock *Flowdock `yaml:"flowdock,omitempty"` 37 } 38 39 func (n *Notification) Send(context *Context) error { 40 // send email notifications 41 if n.Email != nil { 42 n.Email.Send(context) 43 } 44 45 // send email notifications 46 if n.Webhook != nil { 47 n.Webhook.Send(context) 48 } 49 50 // send email notifications 51 if n.Hipchat != nil { 52 n.Hipchat.Send(context) 53 } 54 55 // send irc notifications 56 if n.Irc != nil { 57 n.Irc.Send(context) 58 } 59 60 // send slack notifications 61 if n.Slack != nil { 62 n.Slack.Send(context) 63 } 64 65 // send flowdock notifications 66 if n.Flowdock != nil { 67 n.Flowdock.Send(context) 68 } 69 70 return nil 71 }