MCPcopy
hub / github.com/mcuadros/ofelia / buildMessage

Method buildMessage

middlewares/slack.go:70–100  ·  view source on GitHub ↗
(ctx *core.Context)

Source from the content-addressed store, hash-verified

68}
69
70func (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
102type slackMessage struct {
103 Text string `json:"text"`

Callers 1

pushMessageMethod · 0.95

Calls 2

GetNameMethod · 0.65
GetCommandMethod · 0.65

Tested by

no test coverage detected