diff --git a/slack/main.go b/slack/main.go index 651c801..d758076 100644 --- a/slack/main.go +++ b/slack/main.go @@ -113,13 +113,17 @@ func (s *slackNotifier) writeMessage() (*slack.WebhookMessage, error) { } var clr string + var msgText switch build.Status { case cbpb.Build_SUCCESS: clr = "#22bb33" + msgText = "Build success!" case cbpb.Build_FAILURE, cbpb.Build_INTERNAL_ERROR, cbpb.Build_TIMEOUT: clr = "#bb2124" + msgText = "Build failed or error occurred" default: clr = "#f0ad4e" + msgText = "Build finished with unexpected status" } var buf bytes.Buffer @@ -133,5 +137,5 @@ func (s *slackNotifier) writeMessage() (*slack.WebhookMessage, error) { return nil, fmt.Errorf("failed to unmarshal templating JSON: %w", err) } - return &slack.WebhookMessage{Attachments: []slack.Attachment{{Color: clr, Blocks: blocks}}}, nil + return &slack.WebhookMessage{Attachments: []slack.Attachment{{Color: clr, Blocks: blocks}}, Text: msgText}, nil } diff --git a/slack/main_test.go b/slack/main_test.go index 9e2e786..d1b8597 100644 --- a/slack/main_test.go +++ b/slack/main_test.go @@ -97,6 +97,7 @@ func TestWriteMessage(t *testing.T) { }, }, }}, + Text: "Build success!" } if diff := cmp.Diff(got, want); diff != "" {