@@ -290,13 +290,13 @@ module Webhook = struct
290290 | true -> repo_url
291291 | false -> util_error " unsupported repository %s" repo_url
292292
293- let get_pipeline_config (cfg : Config_t.config ) pipeline_name =
293+ let pipeline_name ({ pipeline = { name; slug; _ } ; _ } : n ) = sprintf " buildkite/%s" (Option. default name slug)
294+
295+ let get_pipeline_config (cfg : Config_t.config ) (n : n ) =
294296 match cfg.status_rules.allowed_pipelines with
295297 | None -> None
296298 | Some allowed_pipelines ->
297- List. find_opt (fun ({ name; _ } : Config_t.pipeline ) -> String. equal name pipeline_name) allowed_pipelines
298-
299- let pipeline_name ({ pipeline = { name; slug; _ } ; _ } : n ) = sprintf " buildkite/%s" (Option. default name slug)
299+ List. find_opt (fun ({ name; _ } : Config_t.pipeline ) -> String. equal name (pipeline_name n)) allowed_pipelines
300300
301301 let repo_key org pipeline = Printf. sprintf " %s/%s" org pipeline
302302
@@ -317,10 +317,9 @@ module Webhook = struct
317317 | _ -> None
318318
319319 let failed_builds_channel_exn cfg n =
320- let pipeline_name = pipeline_name n in
321- match get_pipeline_config cfg pipeline_name with
320+ match get_pipeline_config cfg n with
322321 | Some ({ failed_builds_channel = Some channel ; _ } : Config_t.pipeline ) -> channel
323- | Some _ | None -> util_error " no failed builds channel defined for pipeline %s" pipeline_name
322+ | Some _ | None -> util_error " no failed builds channel defined for pipeline %s" ( pipeline_name n)
324323
325324 (* * builds should be notified in the builds failed channel if:
326325 - the build is failed OR the build is canceled and notify_canceled_builds is true
@@ -329,8 +328,7 @@ module Webhook = struct
329328 - a failed_builds_channel is defined for the pipeline
330329 *)
331330 let notify_fail (cfg : Config_t.config ) (n : n ) =
332- let pipeline_name = pipeline_name n in
333- let pipeline_config = get_pipeline_config cfg pipeline_name in
331+ let pipeline_config = get_pipeline_config cfg n in
334332 (* TODO: For now we don't notify for canceled builds. Can we get more value than troubles from it? *)
335333 let _notify_canceled_build =
336334 match pipeline_config with
@@ -365,11 +363,11 @@ module Webhook = struct
365363 | _ -> false
366364
367365 let mention_user_on_failed_builds (cfg : Config_t.config ) (n : n ) =
368- get_pipeline_config cfg (pipeline_name n)
366+ get_pipeline_config cfg n
369367 |> Option. map_default (fun (config : Config_t.pipeline ) -> config.mention_user_on_failed_builds) true
370368
371369 let get_escalation_threshold (cfg : Config_t.config ) (n : n ) =
372- match get_pipeline_config cfg (pipeline_name n) with
370+ match get_pipeline_config cfg n with
373371 | Some ({ escalate_notifications = false ; _ } : Config_t. pipeline ) | None -> None
374372 | Some { escalate_notifications = true ; escalate_notification_threshold; _ } ->
375373 Some (Ptime.Span. of_int_s (escalate_notification_threshold * 60 * 60 ))
0 commit comments