mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-25 16:48:17 +00:00
Make hipchat notification messages more verbose
This commit is contained in:
parent
6f3997f4e1
commit
9e761c319c
1 changed files with 12 additions and 6 deletions
|
@ -8,9 +8,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
startedMessage = "Building %s, commit %s, author %s"
|
startedMessage = "Building %s (%s) by %s <br> - %s"
|
||||||
successMessage = "<b>Success</b> %s, commit %s, author %s"
|
successMessage = "Success %s (%s) by %s"
|
||||||
failureMessage = "<b>Failed</b> %s, commit %s, author %s"
|
failureMessage = "Failed %s (%s) by %s"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Hipchat struct {
|
type Hipchat struct {
|
||||||
|
@ -34,19 +34,25 @@ func (h *Hipchat) Send(context *model.Request) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *Hipchat) buildLink(context *model.Request) string {
|
||||||
|
repoName := context.Repo.Owner + "/" + context.Repo.Name
|
||||||
|
url := context.Host + "/" + context.Repo.Host + "/" + repoName + "/" + context.Commit.Branch + "/" + context.Commit.Sha
|
||||||
|
return fmt.Sprintf("<a href=\"%s\">%s#%s</a>", url, repoName, context.Commit.ShaShort())
|
||||||
|
}
|
||||||
|
|
||||||
func (h *Hipchat) sendStarted(context *model.Request) error {
|
func (h *Hipchat) sendStarted(context *model.Request) error {
|
||||||
msg := fmt.Sprintf(startedMessage, context.Repo.Name, context.Commit.ShaShort(), context.Commit.Author)
|
|
||||||
return h.send(hipchat.ColorYellow, hipchat.FormatHTML, msg)
|
return h.send(hipchat.ColorYellow, hipchat.FormatHTML, msg)
|
||||||
|
msg := fmt.Sprintf(startedMessage, h.buildLink(context), context.Commit.Branch, context.User.Login, context.Commit.Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Hipchat) sendFailure(context *model.Request) error {
|
func (h *Hipchat) sendFailure(context *model.Request) error {
|
||||||
msg := fmt.Sprintf(failureMessage, context.Repo.Name, context.Commit.ShaShort(), context.Commit.Author)
|
|
||||||
return h.send(hipchat.ColorRed, hipchat.FormatHTML, msg)
|
return h.send(hipchat.ColorRed, hipchat.FormatHTML, msg)
|
||||||
|
msg := fmt.Sprintf(failureMessage, h.buildLink(context), context.Commit.Branch, context.User.Login)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Hipchat) sendSuccess(context *model.Request) error {
|
func (h *Hipchat) sendSuccess(context *model.Request) error {
|
||||||
msg := fmt.Sprintf(successMessage, context.Repo.Name, context.Commit.ShaShort(), context.Commit.Author)
|
|
||||||
return h.send(hipchat.ColorGreen, hipchat.FormatHTML, msg)
|
return h.send(hipchat.ColorGreen, hipchat.FormatHTML, msg)
|
||||||
|
msg := fmt.Sprintf(successMessage, h.buildLink(context), context.Commit.Branch, context.User.Login)
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper function to send Hipchat requests
|
// helper function to send Hipchat requests
|
||||||
|
|
Loading…
Reference in a new issue