Skip to content

Commit

Permalink
fix(jenkins): Stop or delete from queue (#811)
Browse files Browse the repository at this point in the history
Stop a build can mean a) stopping it or b) removing it from queue if hasn't started.
Today, igor, will attempt both if the build has been started. This can cause a 500 from jenkins server which is propagated to orca which then fails to actually complete the cancellation of a pipeline.
(it's mostly harmless but it can cause issues and it also generates a bunch of exception noise)

This change stops the build if it was started OR removes it from the queue if it wasn't started not both
  • Loading branch information
marchello2000 committed Jul 9, 2020
1 parent bf59df0 commit 23bc829
Showing 1 changed file with 9 additions and 9 deletions.
Expand Up @@ -144,19 +144,19 @@ class BuildController {
if (buildNumber != 0 &&
buildService.metaClass.respondsTo(buildService, 'stopRunningBuild')) {
buildService.stopRunningBuild(jobName, buildNumber)
}

// The jenkins api for removing a job from the queue (http://<Jenkins_URL>/queue/cancelItem?id=<queuedBuild>)
// always returns a 404. This try catch block insures that the exception is eaten instead
// of being handled by the handleOtherException handler and returning a 500 to orca
try {
} else {
// The jenkins api for removing a job from the queue (http://<Jenkins_URL>/queue/cancelItem?id=<queuedBuild>)
// always returns a 404. This try catch block insures that the exception is eaten instead
// of being handled by the handleOtherException handler and returning a 500 to orca
try {
if (buildService.metaClass.respondsTo(buildService, 'stopQueuedBuild')) {
buildService.stopQueuedBuild(queuedBuild)
buildService.stopQueuedBuild(queuedBuild)
}
} catch (RetrofitError e) {
} catch (RetrofitError e) {
if (e.response?.status != NOT_FOUND.value()) {
throw e
throw e
}
}
}
}

Expand Down

0 comments on commit 23bc829

Please sign in to comment.