mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
[Jenkinsfile] Constrain abortion of previous running builds triggered by Differential.
This commit is contained in:
19
Jenkinsfile
vendored
19
Jenkinsfile
vendored
@@ -282,18 +282,23 @@ def isUserAborted(error) {
|
||||
}
|
||||
|
||||
def abortPreviousRunningBuilds() {
|
||||
def pname = env.JOB_NAME.split('/')[0]
|
||||
Jenkins.instance.getItemByFullName(env.JOB_NAME).getBuilds().each{ build ->
|
||||
if (params.REVISION_ID == null || isAbortableDifferentialBuild(build)) {
|
||||
def exec = build.getExecutor()
|
||||
|
||||
Jenkins.instance.getItem(pname).getItem(env.JOB_BASE_NAME).getBuilds().each{ build ->
|
||||
def exec = build.getExecutor()
|
||||
|
||||
if (build.number < currentBuild.number && exec != null) {
|
||||
exec.interrupt(Result.ABORTED, new CauseOfInterruption.UserInterruption("Aborted by #${currentBuild.number}"))
|
||||
println("Aborted previous running build #${build.number}")
|
||||
if (build.number < currentBuild.number && exec != null) {
|
||||
exec.interrupt(Result.ABORTED, new CauseOfInterruption.UserInterruption("Aborted by #${currentBuild.number}"))
|
||||
println("Aborted previous running build #${build.number}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def isAbortableDifferentialBuild(build) {
|
||||
def buildEnv = build.getEnvironment(TaskListener.NULL)
|
||||
return buildEnv.containsKey('ABORT_ON_REVISION_ID') && buildEnv.get('ABORT_ON_REVISION_ID') == params.REVISION_ID
|
||||
}
|
||||
|
||||
def notifySlack(nodeName, buildStatus = 'STARTED') {
|
||||
// build status of null means successful
|
||||
buildStatus = buildStatus ?: 'SUCCESS'
|
||||
|
||||
Reference in New Issue
Block a user