cancel running into jenkins_lib

This commit is contained in:
Bryan Stitt 2023-10-23 22:18:02 -07:00
parent 5ab41995a7
commit d09dab846d

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()
}
}
}