From 86c268214a877db5d9afb6f8fb3e043aa90b20b2 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 31 Jan 2020 13:47:11 +0100 Subject: [PATCH] Code fixes --- vars/sendEmail.groovy | 16 +++++++++------- vars/setEnv.groovy | 20 +++++++++++--------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/vars/sendEmail.groovy b/vars/sendEmail.groovy index 9b6d6b2..5f1d4e9 100644 --- a/vars/sendEmail.groovy +++ b/vars/sendEmail.groovy @@ -1,13 +1,15 @@ #!/usr/bin/env groovy def call() { - if (!env.GIT_COMMITTER_EMAIL) { - env.COMMITTER_EMAIL = sh( - script: 'git --no-pager show -s --format="%ae"', - returnStdout: true - ).trim() - } else { - env.COMMITTER_EMAIL = env.GIT_COMMITTER_EMAIL; + script { + if (!env.GIT_COMMITTER_EMAIL) { + env.COMMITTER_EMAIL = sh( + script: 'git --no-pager show -s --format="%ae"', + returnStdout: true + ).trim() + } else { + env.COMMITTER_EMAIL = env.GIT_COMMITTER_EMAIL; + } } sh 'printenv' diff --git a/vars/setEnv.groovy b/vars/setEnv.groovy index bc0a736..5030ccd 100644 --- a/vars/setEnv.groovy +++ b/vars/setEnv.groovy @@ -1,14 +1,16 @@ #!/usr/bin/env groovy def call() { - if (!env.COMMITTER_EMAIL) return - try { - mail( - to: env.COMMITTER_EMAIL, - subject: "Pipeline: ${env.JOB_NAME} (${env.BUILD_NUMBER}): ${currentBuild.currentResult}", - body: "Check status at ${env.BUILD_URL}" - ) - } catch (e) { - echo e.toString() + script { + if (!env.COMMITTER_EMAIL) return + try { + mail( + to: env.COMMITTER_EMAIL, + subject: "Pipeline: ${env.JOB_NAME} (${env.BUILD_NUMBER}): ${currentBuild.currentResult}", + body: "Check status at ${env.BUILD_URL}" + ) + } catch (e) { + echo e.toString() + } } }