mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-19 16:31:01 +00:00
Notify silently on start and success, trigger hipchat notifications only
on fail
This commit is contained in:
parent
9e761c319c
commit
7e021f9eb7
1 changed files with 5 additions and 5 deletions
|
@ -41,22 +41,22 @@ func (h *Hipchat) buildLink(context *model.Request) string {
|
|||
}
|
||||
|
||||
func (h *Hipchat) sendStarted(context *model.Request) error {
|
||||
return h.send(hipchat.ColorYellow, hipchat.FormatHTML, msg)
|
||||
msg := fmt.Sprintf(startedMessage, h.buildLink(context), context.Commit.Branch, context.User.Login, context.Commit.Message)
|
||||
return h.send(hipchat.ColorYellow, hipchat.FormatHTML, msg, false)
|
||||
}
|
||||
|
||||
func (h *Hipchat) sendFailure(context *model.Request) error {
|
||||
return h.send(hipchat.ColorRed, hipchat.FormatHTML, msg)
|
||||
msg := fmt.Sprintf(failureMessage, h.buildLink(context), context.Commit.Branch, context.User.Login)
|
||||
return h.send(hipchat.ColorRed, hipchat.FormatHTML, msg, true)
|
||||
}
|
||||
|
||||
func (h *Hipchat) sendSuccess(context *model.Request) error {
|
||||
return h.send(hipchat.ColorGreen, hipchat.FormatHTML, msg)
|
||||
msg := fmt.Sprintf(successMessage, h.buildLink(context), context.Commit.Branch, context.User.Login)
|
||||
return h.send(hipchat.ColorGreen, hipchat.FormatHTML, msg, false)
|
||||
}
|
||||
|
||||
// helper function to send Hipchat requests
|
||||
func (h *Hipchat) send(color, format, message string) error {
|
||||
func (h *Hipchat) send(color, format, message string, notify bool) error {
|
||||
c := hipchat.Client{AuthToken: h.Token}
|
||||
req := hipchat.MessageRequest{
|
||||
RoomId: h.Room,
|
||||
|
@ -64,7 +64,7 @@ func (h *Hipchat) send(color, format, message string) error {
|
|||
Message: message,
|
||||
Color: color,
|
||||
MessageFormat: format,
|
||||
Notify: true,
|
||||
Notify: notify,
|
||||
}
|
||||
|
||||
return c.PostMessage(req)
|
||||
|
|
Loading…
Reference in a new issue