add jabber_notify function

This commit is contained in:
Benjamin Dauvergne 2022-01-30 15:24:02 +01:00
parent a2673ac19a
commit 19caa233d5
1 changed files with 12 additions and 0 deletions

View File

@ -1,5 +1,17 @@
package eo;
def jabber_notify(currentBuild, env, groupchat = null) {
if (currentBuild.result == null || currentBuild.result == 'SUCCESS') {
return;
}
message = "$currentBuild.fullDisplayName build failed: $currentBuild.absoluteUrl"
if (env.GIT_BRANCH == 'origin/main' && groupchat) {
sh("echo '$message' | sendxmpp -c $groupchat")
} else {
author = sh(returnStdout: true, script: "/usr/bin/git show -s --format='%ae' HEAD | sed s/@entrouvert.*//").trim()
sh("echo '$message' | sendxmpp $author@im.libre-entreprise.com")
}
}
def mail_notify(currentBuild, env, email) {
/* Send mail to 'email' if branch is main