help with workflow-step-api-plugin

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

help with workflow-step-api-plugin

Denis Richtárik

Hello,

I am working on OpenStack Cloud plugin to introduce Declarative Pipeline option. The feature is nearly done, all I need is to delete the OpenStack machine which is supposed to be only temporary and removed once the job is finished.

I am not sure which method to call from Workflow step api plugin.

I have my Step Execution here: https://github.com/drichtarik/openstack-cloud-plugin/blob/JENKINS-47742/src/main/java/jenkins/plugins/openstack/pipeline/OpenStackNodeStepExecution.java

It needs to run ((JCloudsComputer) newSlave.toComputer()).deleteSlave(); as it is in public void stop method. But probably somewhere else? Should I extend something else than SynchronousNonBlockingStepExecution?

Your help would be much appreciated!


Regards

Denis  Richtárik

--
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/47c3189e-edad-c390-f3bc-4576fa1d10ec%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: help with workflow-step-api-plugin

Jesse Glick-4
On Wed, May 16, 2018 at 4:05 PM, Denis Richtárik
<[hidden email]> wrote:
> It needs to run ((JCloudsComputer) newSlave.toComputer()).deleteSlave(); as
> it is in public void stop method. But probably somewhere else? Should I
> extend something else than SynchronousNonBlockingStepExecution?

`stop` will not be called at all typically, and I do not think you
meant for this to be a synchronous step: it looks quite likely to take
more than a trivial amount of time to run, and you need to do cleanup,
meaning that you want a block-scoped step which can do some work
(ideally asynchronously), then invoke its body, then do more work when
the body exits.

It is possible, though not simple, to write something very much like
what you are attempting; while I do not vouch for every detail, you
can look at

https://github.com/jenkinsci/docker-plugin/blob/554bbf8ab937611b17c2c20e9318dace5de3540f/src/main/java/io/jenkins/docker/pipeline/DockerNodeStepExecution.java#L54-L170

If this is a common use case, we could perhaps extract the difficult
boilerplate into some kind of utility in `workflow-durable-task-step`.

Much easier would be to avoid writing a Pipeline step at all, just
implementing `Cloud`, so that a plain old `node` block (perhaps with
some label expression) could be used.

--
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/CANfRfr0XS9wi4PB7t8wHRrdQp2YDMMeKnbs5yMqBQGMh6iz%3DqA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.