-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cancel pending triggered build when parent project is cancelled #363
Conversation
I think I managed to build a test covering it things to do tomorrow:
|
2fc62fc
to
c3acb20
Compare
When a triggering project is cancelled by interrupting its Executor thread and a triggered project is waiting in the build queue (via `waitForStart()`) the InterruptedException is not handled. The tiggered project is properly cancelled, but the triggering project is left in the queue and will eventually run when a slot is available. Catch InterruptException while waiting for the triggered project to start and cancel the queued run. Stacktrace with parameterized-trigger-2.44: org.jenkinsci.plugins.postbuildscript.PostBuildScriptException: java.lang.InterruptedException at org.jenkinsci.plugins.postbuildscript.processor.Processor.processBuildSteps(Processor.java:190) at org.jenkinsci.plugins.postbuildscript.processor.Processor.processScripts(Processor.java:91) at org.jenkinsci.plugins.postbuildscript.processor.Processor.process(Processor.java:79) at org.jenkinsci.plugins.postbuildscript.processor.Processor.process(Processor.java:73) at org.jenkinsci.plugins.postbuildscript.PostBuildScript.perform(PostBuildScript.java:116) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:803) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:752) at hudson.model.Build$BuildExecution.post2(Build.java:177) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:697) at hudson.model.Run.execute(Run.java:1932) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:429) Caused by: java.lang.InterruptedException at java.base/java.lang.Object.wait(Native Method) at java.base/java.lang.Object.wait(Object.java:328) at hudson.remoting.AsyncFutureImpl.get(AsyncFutureImpl.java:79) at hudson.model.queue.FutureImpl.waitForStart(FutureImpl.java:68) at hudson.plugins.parameterizedtrigger.TriggerBuilder.perform(TriggerBuilder.java:146) at org.jenkinsci.plugins.postbuildscript.processor.Processor.processBuildSteps(Processor.java:180) ... 13 more https://phabricator.wikimedia.org/T282893
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much!
jenkinsci/parameterized-trigger-plugin#366 is the pull request to enable continuous delivery in the parameterized trigger plugin. I performed the previous release manually and would rather have the simplification of automated releases since we now have a pending bug fix pull request and a pending enhancement. Bug fix: * jenkinsci/parameterized-trigger-plugin#357 Enhancement: * jenkinsci/parameterized-trigger-plugin#363 I'm not a user of the plugin, so I want to simplfy my contributions to the plugin so that they will be released automatically.
Thanks!! I really appreciate you took a few seconds to thank me about this since I barely know java and that patch took me quite a few hours of sweat to achieve :-] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this contribution. 👍
Cancel triggered build on InterruptException
When a triggering project is cancelled by interrupting its Executor thread and a triggered project is waiting in the build queue (via
waitForStart()
) the InterruptedException is not handled. The tiggered project is properly cancelled, but the triggering project is left in the queue and will eventually run when a slot is available.Catch InterruptException while waiting for the triggered project to start and cancel the queued run.
Stacktrace with parameterized-trigger-2.44:
Reference: https://phabricator.wikimedia.org/T282893
Testing done
I merely wrote a unit test which interrupts the triggering project and assert the triggered downstream project get cancelled.I am most certainly going to deploy the proposed fix to our production.
Submitter checklist