Skip to content

Commit cda40fd

Browse files
lookup users on canceled builds notifications
1 parent cd26b3e commit cda40fd

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

lib/action.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) (Buildkite_api :
359359
| Status n ->
360360
let%lwt channels = partition_status ctx n in
361361
let%lwt slack_user_id =
362-
match Util.Build.is_failed_build n with
362+
match Util.Build.is_failed_build n || Util.Build.is_canceled_build n with
363363
| false -> Lwt.return_none
364364
| true ->
365365
let email = n.commit.commit.author.email in

lib/slack.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,10 @@ let generate_status_notification ?slack_user_id ?failed_steps (cfg : Config_t.co
342342
s
343343
in
344344
let author_mention =
345-
match is_failed_build_notification, slack_user_id, channel with
346-
| true, None, _ | true, _, Status_notification.User _ -> author.email
347-
| _, Some id, Channel _ -> sprintf "<@%s>" (Slack_user_id.project id)
348-
| _ -> ""
345+
match Build.(is_failed_build n || is_canceled_build n), slack_user_id, channel with
346+
| true, None, Channel _ -> author.email
347+
| true, Some id, Channel _ -> sprintf "<@%s>" (Slack_user_id.project id)
348+
| true, _, User _ | false, _, _ -> ""
349349
in
350350
let commit_info = [ sprintf "*Commit*: `<%s|%s>` %s" html_url (git_short_sha_hash sha) author_mention ] in
351351
let branches_info =

test/slack_payloads.expected

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ will notify #longest-a1
529529
will notify #failed-builds
530530
{
531531
"channel": "failed-builds",
532-
"text": "<https://buildkite.com/ahrefs/pipeline2|[buildkite/pipeline2]>: Build <https://buildkite.com/ahrefs/pipeline2/builds/181734|#​181734> canceled by author (7 minutes, 29 seconds) for \"<https://github.com/ahrefs/monorepo/commit/7e0a933e9c71b4ca107680ca958ca1888d5e479b|c1 message>\" author@ahrefs.com",
532+
"text": "<https://buildkite.com/ahrefs/pipeline2|[buildkite/pipeline2]>: Build <https://buildkite.com/ahrefs/pipeline2/builds/181734|#​181734> canceled by author (7 minutes, 29 seconds) for \"<https://github.com/ahrefs/monorepo/commit/7e0a933e9c71b4ca107680ca958ca1888d5e479b|c1 message>\" <@id[author@ahrefs.com]>",
533533
"attachments": [
534534
{
535535
"fallback": null,
@@ -544,7 +544,7 @@ will notify #failed-builds
544544
will notify #failed-builds
545545
{
546546
"channel": "failed-builds",
547-
"text": "<https://buildkite.com/ahrefs/pipeline2|[buildkite/pipeline2]>: Build <https://buildkite.com/ahrefs/pipeline2/builds/181734|#​181734> canceled by author (7 minutes, 29 seconds) for \"<https://github.com/ahrefs/monorepo/commit/7e0a933e9c71b4ca107680ca958ca1888d5e479b|c1 message>\" author@ahrefs.com",
547+
"text": "<https://buildkite.com/ahrefs/pipeline2|[buildkite/pipeline2]>: Build <https://buildkite.com/ahrefs/pipeline2/builds/181734|#​181734> canceled by author (7 minutes, 29 seconds) for \"<https://github.com/ahrefs/monorepo/commit/7e0a933e9c71b4ca107680ca958ca1888d5e479b|c1 message>\" <@id[author@ahrefs.com]>",
548548
"attachments": [
549549
{
550550
"fallback": null,
@@ -559,7 +559,7 @@ will notify #failed-builds
559559
will notify #failed-builds
560560
{
561561
"channel": "failed-builds",
562-
"text": "<https://buildkite.com/ahrefs/pipeline2|[buildkite/pipeline2]>: Build <https://buildkite.com/ahrefs/pipeline2/builds/181734|#​181734> canceled by author (7 minutes, 29 seconds) for \"<https://github.com/ahrefs/monorepo/commit/7e0a933e9c71b4ca107680ca958ca1888d5e479b|c1 message>\" author@ahrefs.com",
562+
"text": "<https://buildkite.com/ahrefs/pipeline2|[buildkite/pipeline2]>: Build <https://buildkite.com/ahrefs/pipeline2/builds/181734|#​181734> canceled by author (7 minutes, 29 seconds) for \"<https://github.com/ahrefs/monorepo/commit/7e0a933e9c71b4ca107680ca958ca1888d5e479b|c1 message>\" <@id[author@ahrefs.com]>",
563563
"attachments": [
564564
{
565565
"fallback": null,

0 commit comments

Comments
 (0)