test abort last job
This commit is contained in:
parent
9d52d7983f
commit
b6e3d4e351
|
@ -6,37 +6,56 @@ node {
|
||||||
}
|
}
|
||||||
|
|
||||||
def skipstage=0
|
def skipstage=0
|
||||||
def abortPreviousBuilds() {
|
def cancelPreviousBuilds() {
|
||||||
def currentJobName = env.JOB_NAME
|
def jobName = env.JOB_NAME
|
||||||
def currentBuildNumber = env.BUILD_NUMBER.toInteger()
|
def buildNumber = env.BUILD_NUMBER.toInteger()
|
||||||
def jobs = Jenkins.instance.getItemByFullName(currentJobName)
|
/* Get job name */
|
||||||
def builds = jobs.getBuilds()
|
def currentJob = Jenkins.instance.getItemByFullName(jobName)
|
||||||
|
|
||||||
for (build in builds) {
|
/* Iterating over the builds for specific job */
|
||||||
if (!build.isBuilding()) {
|
for (def build : currentJob.builds) {
|
||||||
continue;
|
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()) {
|
// for (build in builds) {
|
||||||
continue;
|
// if (!build.isBuilding()) {
|
||||||
}
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
build.doKill() //doTerm(),doKill(),doTerm()
|
// if (currentBuildNumber == build.getNumber().toInteger()) {
|
||||||
}
|
// continue;
|
||||||
}
|
// }
|
||||||
//abort previous build
|
|
||||||
abortPreviousBuilds()
|
// build.doKill() //doTerm(),doKill(),doTerm()
|
||||||
def abort_previous(){
|
// }
|
||||||
def buildNumber = env.BUILD_NUMBER as int
|
// }
|
||||||
if (buildNumber > 1) milestone(buildNumber - 1)
|
// //abort previous build
|
||||||
milestone(buildNumber)
|
// abortPreviousBuilds()
|
||||||
}
|
// def abort_previous(){
|
||||||
|
// def buildNumber = env.BUILD_NUMBER as int
|
||||||
|
// if (buildNumber > 1) milestone(buildNumber - 1)
|
||||||
|
// milestone(buildNumber)
|
||||||
|
// }
|
||||||
def pre_test(){
|
def pre_test(){
|
||||||
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
|
|
||||||
sh '''
|
sh '''
|
||||||
sudo rmtaos
|
sudo rmtaos || echo "taosd has not installed"
|
||||||
'''
|
'''
|
||||||
}
|
|
||||||
sh '''
|
sh '''
|
||||||
|
|
||||||
cd ${WKC}
|
cd ${WKC}
|
||||||
|
|
Loading…
Reference in New Issue