Although you tried to make your step asynchronous, it is not actually 
asynchronous. `execMatlabCommand` runs during your StepExecution’s `start` 
method and internally calls `Process.join` to wait for the process to complete, 
so your `start` method doesn’t return until the process completed. Another 
indication that your step is not asynchronous is that you call 
`getContext().onSuccess(true);` before you `return false` from the step, 
meaning that your step has already completed.

You need to change things so that your step starts the command and then sets up 
a background process to check its status periodically to know if it is 
completed. Doing this for external processes is somewhat complex, but you could 
look at the `sh` and `bat` steps for an example.

Stepping back a little bit, I would try to investigate to see if you could 
implement this plugin’s functionality in a different way (maybe a block-scoped 
step that sets up environment variables, etc. as needed) and just have users 
use the standard `sh` and `bat` steps to launch the Matlab command so that you 
do not have to reimplement that functionality.


> On Jul 23, 2020, at 12:18, Nikhil Bhoski <[email protected]> wrote:
> 
> Hi Gavin ,
> 
> The stop is implemented as per the doc which Jesse shared. it reads like below
>  But i get your point now and i guess i should kill the process in stop. any 
> ideas on how could i get access to the process in stop () ? 
> 
> You should also implement stop to terminate the step. It could simply read
> 
> getContext().onFailure(cause);
> 
> On Thursday, 23 July 2020 21:22:12 UTC+5:30, Gavin Mogan wrote:
> Its been a long time since i wrote plugins using these APIs but how come your 
> on stop isn't doing anything? Shouldn't it kill the process?
> 
> On Thu., Jul. 23, 2020, 8:48 a.m. Nikhil Bhoski, <[email protected]> wrote:
> Thanks Jesse,
> 
>  I had referred the same doc and i guess i am following as per 
> recommendation. Here is my step execution class 
> 
> https://github.com/jenkinsci/matlab-plugin/blob/master/src/main/java/com/mathworks/ci/MatlabCommandStepExecution.java
>  
> 
> Which will be called in 
> 
> https://github.com/jenkinsci/matlab-plugin/blob/master/src/main/java/com/mathworks/ci/RunMatlabCommandStep.java
> 
> Thanks & Regards
> Nikhil
> 
> On Thursday, 23 July 2020 19:09:30 UTC+5:30, Jesse Glick wrote:
> On Thu, Jul 23, 2020 at 3:47 AM Nikhil Bhoski <[email protected]> wrote: 
> > when i use this step with options block with 6 minutes pause  as shown 
> > below.my step does not seem to have any effect of this overriden timeout 
> > value . It always gets terminated after 5 minutes 
> 
> You are most likely blocking the whole CPS VM thread, which is illegal. See: 
> 
> https://github.com/jenkinsci/workflow-step-api-plugin/blob/master/README.md#creating-an-asynchronous-step
>  
> 
> -- 
> 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 [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jenkinsci-dev/12357eb4-d90e-4494-8c6f-619c22a718a4o%40googlegroups.com.
> 
> -- 
> 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 [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jenkinsci-dev/47dea698-df6c-485d-9df3-9230e305c480o%40googlegroups.com.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/91BD05DA-0580-4393-B6F6-DE321FA3798B%40cloudbees.com.

Reply via email to