cancel running into jenkins_lib
This commit is contained in:
parent
5ab41995a7
commit
d09dab846d
10
Jenkinsfile
vendored
10
Jenkinsfile
vendored
@ -21,15 +21,7 @@ pipeline {
|
||||
stage('Check and Cancel Old Builds') {
|
||||
steps {
|
||||
script {
|
||||
def jobName = env.JOB_NAME
|
||||
def buildNumber = env.BUILD_NUMBER.toInteger()
|
||||
|
||||
// Get all running builds of the current job
|
||||
def job = Jenkins.instance.getItemByFullName(jobName)
|
||||
def runningBuilds = job.builds.findAll { it.isBuilding() && it.number < buildNumber }
|
||||
|
||||
// Cancel running builds
|
||||
runningBuilds.each { it.doStop() }
|
||||
myCancelRunning.cancelRunning()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user