From da78c3af789c49918d14a3c14c13cbf6aac46408 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Tue, 23 Mar 2021 12:27:54 +0800 Subject: [PATCH] recover --- Jenkinsfile | 82 ++++++++++++++++++++++++++--------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ff9327f603..71214d1495 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,51 +6,51 @@ node { } def skipstage=0 -def cancelPreviousBuilds() { - def jobName = env.JOB_NAME - def buildNumber = env.BUILD_NUMBER.toInteger() - /* Get job name */ - def currentJob = Jenkins.instance.getItemByFullName(jobName) +// def cancelPreviousBuilds() { +// def jobName = env.JOB_NAME +// def buildNumber = env.BUILD_NUMBER.toInteger() +// /* Get job name */ +// def currentJob = Jenkins.instance.getItemByFullName(jobName) - /* Iterating over the builds for specific job */ - for (def build : currentJob.builds) { - def exec = build.getExecutor() - /* If there is a build that is currently running and it's not current build */ - if (build.isBuilding() && build.number.toInteger() != buildNumber && exec != null) { - /* Then stop it */ - exec.interrupt( - Result.ABORTED, - new CauseOfInterruption.UserInterruption("Aborted by #${currentBuild.number}") - ) - println("Aborted previously running build #${build.number}") - } - } -} -// def abortPreviousBuilds() { -// def currentJobName = env.JOB_NAME -// def currentBuildNumber = env.BUILD_NUMBER.toInteger() -// def jobs = Jenkins.instance.getItemByFullName(currentJobName) -// def builds = jobs.getBuilds() - -// for (build in builds) { -// if (!build.isBuilding()) { -// continue; +// /* Iterating over the builds for specific job */ +// for (def build : currentJob.builds) { +// def exec = build.getExecutor() +// /* If there is a build that is currently running and it's not current build */ +// if (build.isBuilding() && build.number.toInteger() != buildNumber && exec != null) { +// /* Then stop it */ +// exec.interrupt( +// Result.ABORTED, +// new CauseOfInterruption.UserInterruption("Aborted by #${currentBuild.number}") +// ) +// println("Aborted previously running build #${build.number}") +// } // } +// } +def abortPreviousBuilds() { + def currentJobName = env.JOB_NAME + def currentBuildNumber = env.BUILD_NUMBER.toInteger() + def jobs = Jenkins.instance.getItemByFullName(currentJobName) + def builds = jobs.getBuilds() -// if (currentBuildNumber == build.getNumber().toInteger()) { -// continue; -// } + for (build in builds) { + if (!build.isBuilding()) { + continue; + } -// build.doKill() //doTerm(),doKill(),doTerm() -// } -// } - //abort previous build -// abortPreviousBuilds() -// def abort_previous(){ -// def buildNumber = env.BUILD_NUMBER as int -// if (buildNumber > 1) milestone(buildNumber - 1) -// milestone(buildNumber) -// } + if (currentBuildNumber == build.getNumber().toInteger()) { + continue; + } + + build.doKill() //doTerm(),doKill(),doTerm() + } +} +// abort previous build +abortPreviousBuilds() +def abort_previous(){ + def buildNumber = env.BUILD_NUMBER as int + if (buildNumber > 1) milestone(buildNumber - 1) + milestone(buildNumber) +} def pre_test(){ sh ''' -- GitLab