How to add support for InterruptedException to a plugin?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to add support for InterruptedException to a plugin?

Daniel Anechitoaie
Hi,

Any idea how can I add support for InterruptedException to my plugin?
I have a builder plugin that zips some files from the workspace and then uploads them on a remote server.

The flow is basically like this:

---
public void perform(@Nonnull Run<?, ?> build, @Nonnull FilePath workspace,
                        @Nonnull Launcher launcher, @Nonnull TaskListener listener) throws IOException {

    launcher.getChannel().call(deployCallable);
}
---

deployCallable is an instance of a inner class described bellow:

---
private static class DeployCallable extends MasterToSlaveCallable<Boolean, InterruptedException> { // So it works in master/slave setup

        private static final long serialVersionUID = 1L;

        public Boolean call() throws InterruptedException {
               for folder in path {
                      zip(folder);
               }

               for zip in zipFiles {
                      upload(zip); // Using Apache HTTP Client
               }
        }
}
---


The problem is that that if I click cancel on the job it still runs until by build step is finished and all files are zipped and uploaded and only then it marks the build as aborted.
Is there any way to check from my plugin if the job was aborted and just stop wherever I am in the build?
Let's say I just created the zips and user clicks on cancel, how do I stop here and not also upload all zips?

Thank you.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/dd13bde5-830d-49c9-a18d-a41d555e2e7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to add support for InterruptedException to a plugin?

Jesse Glick-4
On Mon, Aug 28, 2017 at 8:00 AM, Daniel Anechitoaie
<[hidden email]> wrote:
> The problem is that that if I click cancel on the job it still runs until by
> build step is finished and all files are zipped and uploaded and only then
> it marks the build as aborted.
> Is there any way to check from my plugin if the job was aborted and just
> stop wherever I am in the build?

I do not think so. Sounds like an RFE for Jenkins core / Remoting:
interrupting a synchronous remote call should `Thread.interrupt` the
corresponding thread on the remote side.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2RSxnsLGY9JbKOQWxXKXR1gFxcqrh4sLhFjhiEc0d9Yg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to add support for InterruptedException to a plugin?

Daniel Anechitoaie
How do I create a request for enhancement for Jenkins?
I can try and do this and hopefully someone that has experience will implement it at some point, but not sore where and how to create this RFE.


On Monday, August 28, 2017 at 3:19:12 PM UTC+3, Jesse Glick wrote:
On Mon, Aug 28, 2017 at 8:00 AM, Daniel Anechitoaie
<<a href="javascript:" target="_blank" gdf-obfuscated-mailto="gVlkvMfSAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">danie...@...> wrote:
> The problem is that that if I click cancel on the job it still runs until by
> build step is finished and all files are zipped and uploaded and only then
> it marks the build as aborted.
> Is there any way to check from my plugin if the job was aborted and just
> stop wherever I am in the build?

I do not think so. Sounds like an RFE for Jenkins core / Remoting:
interrupting a synchronous remote call should `Thread.interrupt` the
corresponding thread on the remote side.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/4603f8b5-7f5e-4964-8a91-6dd1f4e2acd6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to add support for InterruptedException to a plugin?

Denys Digtiar
You can refer to https://wiki.jenkins.io/display/JENKINS/How+to+report+an+issue to learn about the process.

On Monday, August 28, 2017 at 11:53:45 PM UTC+10, Daniel Anechitoaie wrote:
How do I create a request for enhancement for Jenkins?
I can try and do this and hopefully someone that has experience will implement it at some point, but not sore where and how to create this RFE.


On Monday, August 28, 2017 at 3:19:12 PM UTC+3, Jesse Glick wrote:
On Mon, Aug 28, 2017 at 8:00 AM, Daniel Anechitoaie
<[hidden email]> wrote:
> The problem is that that if I click cancel on the job it still runs until by
> build step is finished and all files are zipped and uploaded and only then
> it marks the build as aborted.
> Is there any way to check from my plugin if the job was aborted and just
> stop wherever I am in the build?

I do not think so. Sounds like an RFE for Jenkins core / Remoting:
interrupting a synchronous remote call should `Thread.interrupt` the
corresponding thread on the remote side.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/130da1c5-d02b-4bf1-91b7-d49bfd91120f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to add support for InterruptedException to a plugin?

Daniel Anechitoaie
Thanks.

On Monday, September 4, 2017 at 4:10:39 AM UTC+3, Denys Digtiar wrote:
You can refer to <a href="https://wiki.jenkins.io/display/JENKINS/How+to+report+an+issue" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FHow%2Bto%2Breport%2Ban%2Bissue\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGhwhYpR1mrvq9dfWpT0be6Craq-Q&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FHow%2Bto%2Breport%2Ban%2Bissue\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGhwhYpR1mrvq9dfWpT0be6Craq-Q&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/How+to+report+an+issue to learn about the process.

On Monday, August 28, 2017 at 11:53:45 PM UTC+10, Daniel Anechitoaie wrote:
How do I create a request for enhancement for Jenkins?
I can try and do this and hopefully someone that has experience will implement it at some point, but not sore where and how to create this RFE.


On Monday, August 28, 2017 at 3:19:12 PM UTC+3, Jesse Glick wrote:
On Mon, Aug 28, 2017 at 8:00 AM, Daniel Anechitoaie
<[hidden email]> wrote:
> The problem is that that if I click cancel on the job it still runs until by
> build step is finished and all files are zipped and uploaded and only then
> it marks the build as aborted.
> Is there any way to check from my plugin if the job was aborted and just
> stop wherever I am in the build?

I do not think so. Sounds like an RFE for Jenkins core / Remoting:
interrupting a synchronous remote call should `Thread.interrupt` the
corresponding thread on the remote side.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/2a3a139c-f265-4aa0-ae9a-a1c01b95721b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.