Skip to content

Commit

Permalink
add fallback email in status notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
thatportugueseguy committed Jan 27, 2025
1 parent f173529 commit 2f4a80c
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/slack.ml
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ let generate_status_notification ?slack_user_id ?failed_steps (cfg : Config_t.co
(notification : status_notification) channel =
let { commit; state; description; target_url; context; repository; _ } = notification in
let ({ commit : inner_commit; sha; html_url; _ } : status_commit) = commit in
let ({ message; _ } : inner_commit) = commit in
let ({ message; author; _ } : inner_commit) = commit in
let is_buildkite = String.starts_with context ~prefix:"buildkite" in
let is_failed_build_notification =
let is_failed_builds_channel =
Expand Down Expand Up @@ -348,7 +348,7 @@ let generate_status_notification ?slack_user_id ?failed_steps (cfg : Config_t.co
in
let author_mention =
match slack_user_id, channel with
| None, _ | _, Status_notification.User _ -> ""
| None, _ | _, Status_notification.User _ -> author.email
| Some id, Channel _ -> sprintf "<@%s>" (Slack_user_id.project id)
in
let commit_info = [ sprintf "*Commit*: `<%s|%s>` %s" html_url (git_short_sha_hash sha) author_mention ] in
Expand Down
70 changes: 70 additions & 0 deletions state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"repos": {
"https://github.com/thatportugueseguy/buildkite-starter": {
"pipeline_statuses": {
"buildkite-tests": {
"main": {
"469": {
"status": "failure",
"build_number": 469,
"build_url": "https://buildkite.com/monorobot-tests/buildkite-tests/builds/469",
"commit": {
"sha": "2ec912cecd53c07c699f2d0317e7667353c4eb02",
"author": "[email protected]",
"commit_message": "fail 1, notify"
},
"is_finished": true,
"failed_steps": [
{
"name": "buildkite/buildkite-tests/fail",
"build_url": "https://buildkite.com/monorobot-tests/buildkite-tests/builds/469#0194a76b-fac1-41fd-87e4-f1ae7b2968bd"
},
{
"name": "buildkite/buildkite-tests/trigger-infra",
"build_url": "https://buildkite.com/monorobot-tests/buildkite-tests/builds/469#0194a76b-faca-4585-97ce-d3e1f142b4f3"
}
],
"created_at": "2025-01-27T11:00:55-00:00",
"finished_at": "2025-01-27T11:01:08-00:00"
}
}
},
"infra": {
"main": {
"83": {
"status": "failure",
"build_number": 83,
"build_url": "https://buildkite.com/monorobot-tests/infra/builds/83#0194a76c-01ac-4b43-8737-3cf1c988c02f",
"commit": {
"sha": "2ec912cecd53c07c699f2d0317e7667353c4eb02",
"author": "[email protected]",
"commit_message": "fail 1, notify"
},
"is_finished": true,
"failed_steps": [
{
"name": "buildkite/infra/infra-coiso",
"build_url": "https://buildkite.com/monorobot-tests/infra/builds/83#0194a76c-01a9-441c-9971-7736adb84c0c"
},
{
"name": "buildkite/infra/test-whouseuu-ttt",
"build_url": "https://buildkite.com/monorobot-tests/infra/builds/83#0194a76c-01ac-4b43-8737-3cf1c988c02f"
}
],
"created_at": "2025-01-27T11:01:05-00:00",
"finished_at": null
}
}
}
},
"pipeline_commits": {
"buildkite-tests": {
"main": {
"s1": [ "2ec912cecd53c07c699f2d0317e7667353c4eb02" ],
"s2": []
}
}
}
}
}
}

0 comments on commit 2f4a80c

Please sign in to comment.