From 19caa233d5c2d4c554afc509c050254810ad9bee Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Sun, 30 Jan 2022 15:24:02 +0100 Subject: [PATCH] add jabber_notify function --- src/eo/Utils.groovy | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/eo/Utils.groovy b/src/eo/Utils.groovy index 299ac65..084b62a 100644 --- a/src/eo/Utils.groovy +++ b/src/eo/Utils.groovy @@ -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