From 0a6243f3115e502de1028a1a5c36e893d0740a7b Mon Sep 17 00:00:00 2001 From: Jan Zarzycki Date: Mon, 4 Nov 2024 10:23:39 +0100 Subject: [PATCH] SRE-2335 Add repo-based email notifications Signed-off-by: Jan Zarzycki --- vars/notifyBrokenBranch.groovy | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/vars/notifyBrokenBranch.groovy b/vars/notifyBrokenBranch.groovy index de089482b..4df4f3d7f 100644 --- a/vars/notifyBrokenBranch.groovy +++ b/vars/notifyBrokenBranch.groovy @@ -35,14 +35,21 @@ def call(Map config = [:]) { onPR: config['onPR'] def branch = env['GIT_BRANCH'].toUpperCase().replaceAll("-", "_") - def watchers = env["DAOS_STACK_${branch}_WATCHER"] + def git_suffix = ~/\.git$/ + def repo_name = GIT_URL.tokenize('/')[-1] - git_suffix + repo_name = repo_name.toUpperCase().replaceAll("-", "_") - if (watchers != "null") { - emailextDaos body: env.GIT_BRANCH + ' is broken.\n\n' + - 'See ' + env.BUILD_URL + ' for more details.', - to: watchers, - subject: 'Build broken on ' + env.GIT_BRANCH, - onPR: config['onPR'] + def vars = ["DAOS_STACK_WATCHER_${repo_name}", "DAOS_STACK_${branch}_WATCHER"] + for (var in vars) { + def watchers = env[var] + if (watchers != "null") { + emailextDaos body: env.GIT_BRANCH + ' is broken.\n\n' + + 'See ' + env.BUILD_URL + ' for more details.', + to: watchers, + subject: 'Build broken on ' + env.GIT_BRANCH, + onPR: config['onPR'] + break + } } }