nswamy commented on a change in pull request #8034: Kill running PR builds when
a new build is triggered for the same PR
URL: https://github.com/apache/incubator-mxnet/pull/8034#discussion_r140923014
##########
File path: Jenkinsfile
##########
@@ -11,14 +11,36 @@ max_time = 120
// assign any caught errors here
err = null
+//Method to Kill PR Builds that are running currently when a new build is
triggered.
+def abortPreviousRunningBuilds() {
+ def hi = Hudson.instance
+ def pname = env.JOB_NAME.split('/')[0]
+
+ hi.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}")
+ } else {
+ println("Build is not running or is current build, not aborting -
#${build.number}")
Review comment:
please remove the else part in your next commit after you have verified that
everything works. no need to print 'not running' every time.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services