提交 b6e3d4e3 编写于 作者: L liuyq-617

test abort last job

上级 9d52d798
......@@ -6,37 +6,56 @@ node {
}
def skipstage=0
def abortPreviousBuilds() {
def currentJobName = env.JOB_NAME
def currentBuildNumber = env.BUILD_NUMBER.toInteger()
def jobs = Jenkins.instance.getItemByFullName(currentJobName)
def builds = jobs.getBuilds()
def cancelPreviousBuilds() {
def jobName = env.JOB_NAME
def buildNumber = env.BUILD_NUMBER.toInteger()
/* Get job name */
def currentJob = Jenkins.instance.getItemByFullName(jobName)
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(){
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh '''
sudo rmtaos
'''
}
sh '''
sudo rmtaos || echo "taosd has not installed"
'''
sh '''
cd ${WKC}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册