(ctx *core.Context)
| 68 | } |
| 69 | |
| 70 | func (m *Slack) buildMessage(ctx *core.Context) *slackMessage { |
| 71 | msg := &slackMessage{ |
| 72 | Username: slackUsername, |
| 73 | IconURL: slackAvatarURL, |
| 74 | } |
| 75 | |
| 76 | msg.Text = fmt.Sprintf( |
| 77 | "Job *%q* finished in *%s*, command `%s`", |
| 78 | ctx.Job.GetName(), ctx.Execution.Duration, ctx.Job.GetCommand(), |
| 79 | ) |
| 80 | |
| 81 | if ctx.Execution.Failed { |
| 82 | msg.Attachments = append(msg.Attachments, slackAttachment{ |
| 83 | Title: "Execution failed", |
| 84 | Text: ctx.Execution.Error.Error(), |
| 85 | Color: "#F35A00", |
| 86 | }) |
| 87 | } else if ctx.Execution.Skipped { |
| 88 | msg.Attachments = append(msg.Attachments, slackAttachment{ |
| 89 | Title: "Execution skipped", |
| 90 | Color: "#FFA500", |
| 91 | }) |
| 92 | } else { |
| 93 | msg.Attachments = append(msg.Attachments, slackAttachment{ |
| 94 | Title: "Execution successful", |
| 95 | Color: "#7CD197", |
| 96 | }) |
| 97 | } |
| 98 | |
| 99 | return msg |
| 100 | } |
| 101 | |
| 102 | type slackMessage struct { |
| 103 | Text string `json:"text"` |
no test coverage detected