From 6ccf7cb9d25cde33cdaf72b7230605802dc04bf4 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Thu, 1 Feb 2018 11:48:13 +1000 Subject: [PATCH] move Method def outside of the loop Signed-off-by: olivier lamy --- Jenkinsfile | 69 ++++++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0e38618575a..e86f92f5099 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -120,37 +120,40 @@ for (def jdk in jdks) { } } - // True if this build is part of the "active" branches - // for Jetty. - def isActiveBranch() +} + + +// True if this build is part of the "active" branches +// for Jetty. +def isActiveBranch() +{ + def branchName = "${env.BRANCH_NAME}" + return ( branchName == "master" || + branchName.startsWith("jetty-") ); +} + +// Test if the Jenkins Pipeline or Step has marked the +// current build as unstable +def isUnstable() +{ + return currentBuild.result == "UNSTABLE" +} + +// Send a notification about the build status +def notifyBuild(String buildStatus) +{ + if ( !isActiveBranch() ) { - def branchName = "${env.BRANCH_NAME}" - return ( branchName == "master" || - branchName.startsWith("jetty-") ); + // don't send notifications on transient branches + return } - // Test if the Jenkins Pipeline or Step has marked the - // current build as unstable - def isUnstable() - { - return currentBuild.result == "UNSTABLE" - } + // default the value + buildStatus = buildStatus ?: "UNKNOWN" - // Send a notification about the build status - def notifyBuild(String buildStatus) - { - if ( !isActiveBranch() ) - { - // don't send notifications on transient branches - return - } - - // default the value - buildStatus = buildStatus ?: "UNKNOWN" - - def email = "${env.EMAILADDRESS}" - def summary = "${env.JOB_NAME}#${env.BUILD_NUMBER} - ${buildStatus}" - def detail = """

Job: ${env.JOB_NAME} [#${env.BUILD_NUMBER}]

+ def email = "${env.EMAILADDRESS}" + def summary = "${env.JOB_NAME}#${env.BUILD_NUMBER} - ${buildStatus}" + def detail = """

Job: ${env.JOB_NAME} [#${env.BUILD_NUMBER}]

${buildStatus}

@@ -159,11 +162,11 @@ for (def jdk in jdks) {
Build${env.BUILD_URL}
""" - emailext ( - to: email, - subject: summary, - body: detail - ) - } + emailext ( + to: email, + subject: summary, + body: detail + ) } + // vim: et:ts=2:sw=2:ft=groovy \ No newline at end of file