This commit is contained in:
parent
de5dc0d49c
commit
5d2272dc85
1 changed files with 15 additions and 1 deletions
16
main.go
16
main.go
|
|
@ -143,6 +143,19 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func bodyString(s string, d templateData) string {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
t, err := template.New("message").Parse(s)
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
err = t.Execute(&buf, d)
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return buf.String()
|
||||||
|
}
|
||||||
|
|
||||||
func card(d templateData) ([]byte, error) {
|
func card(d templateData) ([]byte, error) {
|
||||||
switch d.Status {
|
switch d.Status {
|
||||||
case "success":
|
case "success":
|
||||||
|
|
@ -158,7 +171,8 @@ func card(d templateData) ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.EventBody == "" {
|
if d.EventBody == "" {
|
||||||
d.EventBody = "<b>Project:</b> {{ .Project }}<br><b>Commit-id:</b> <font color=\"#FF0000\">{{ .Commit }}</font><br><b>Branch:</b> <font color=\"#00FF00f\">{{ .Branch }}</font><br><b>Build Status:</b> <font color=\"#0000ff\">{{ .Status }}</font>"
|
d.EventBody = bodyString("<b>Project:</b> {{ .Project }}<br><b>Commit-id:</b> <font color=\"#FF0000\">{{ .Commit }}</font><br><b>Branch:</b> <font color=\"#00FF00f\">{{ .Branch }}</font><br><b>Build Status:</b> <font color=\"#0000ff\">{{ .Status }}</font>", d)
|
||||||
|
// d.EventBody = "<b>Project:</b> {{ .Project }}<br><b>Commit-id:</b> <font color=\"#FF0000\">{{ .Commit }}</font><br><b>Branch:</b> <font color=\"#00FF00f\">{{ .Branch }}</font><br><b>Build Status:</b> <font color=\"#0000ff\">{{ .Status }}</font>"
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.Status == "success" {
|
if d.Status == "success" {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue