Good pratices for workflow plugin support

94 views
Skip to first unread message

jcsirot

unread,
Sep 15, 2015, 9:24:39 AM9/15/15
to Jenkins Developers
Hi,

I am currently working on the support of the workflow plugin for the ansible plugin and I'm facing some questions.

1. I wonder which versions of jenkins and workflow plugin I should use in the pom.xml? For the moment I'm using Jenkins 1.580.1 and workflow 1.4.2 but the docker workflow plugin is using Jenkins 1.596.1 and workflow 1.7-alpha-1.

2. Should I extend AbstractSynchronousNonBlockingStepExecution or AbstractStepExecutionImpl? I'm not sure the clearly understand the impact of synchronous and asynchronous executions on the workflow engine. An example of AbstractStepExecutionImpl implementation would be greatly appreciated :-)

3. Should I upgrade the Builder subclass to implement the SimpleBuildStep interface?

Thanks in advance for your replies and advice.

Antonio Muñiz

unread,
Sep 15, 2015, 2:27:39 PM9/15/15
to jenkin...@googlegroups.com
> I wonder which versions of jenkins and workflow plugin I should use in the pom.xml?

It depends on what APIs your plugin is using.
Useful information here:
https://github.com/jenkinsci/workflow-plugin/blob/master/COMPATIBILITY.md#build-steps

> Should I extend AbstractSynchronousNonBlockingStepExecution or AbstractStepExecutionImpl?

I guess you want to run some external task (ansible), so probably you
want to extend AbstractSynchronousNonBlockingStepExecution, since it
does not block the CPS VM thread (it runs in a separate thread).

> An example of AbstractStepExecutionImpl implementation would be greatly appreciated

AbstractSynchronousNonBlockingStepExecution is a partial example :-)
But there are many more, for example:
https://github.com/jenkinsci/workflow-plugin/blob/c2afa61d28b2922df955bf7f6b45e456e898c10c/basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/SleepStep.java

> Should I upgrade the Builder subclass to implement the SimpleBuildStep interface?

Sure. Following the rules in the Javadoc:
http://javadoc.jenkins-ci.org/jenkins/tasks/SimpleBuildStep.html
> --
> 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 jenkinsci-de...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-dev/a2112371-9617-4c9a-9dd7-dd9c37fb0266%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Antonio Muñiz
Software Engineer
CloudBees, Inc.

Jesse Glick

unread,
Sep 15, 2015, 2:28:16 PM9/15/15
to Jenkins Dev
On Tue, Sep 15, 2015 at 9:24 AM, jcsirot <jcs...@gmail.com> wrote:
> I am currently working on the support of the workflow plugin for the ansible
> plugin and I'm facing some questions.

Happy to help! BTW if you have a PR in progress, feel free to CC
@jglick on it. Also if there is a JIRA issue open, mark with the
`workflow` label, and make sure
`jenkinsci/workflow-plugin/COMPATIBILITY.md` links to it.

Did you attend my recent Office Hour on Workflow-related plugin
development, or watch the recorded video?
https://www.youtube.com/watch?v=4zdy7XGx3PA

Also: https://github.com/jenkinsci/workflow-plugin/blob/master/COMPATIBILITY.md#plugin-developer-guide

> 1. I wonder which versions of jenkins and workflow plugin I should use in
> the pom.xml? For the moment I'm using Jenkins 1.580.1 and workflow 1.4.2 but
> the docker workflow plugin is using Jenkins 1.596.1 and workflow
> 1.7-alpha-1.

Or the latest versions of Workflow (1.8+) requires 1.609.1+. Up to
you; depends on your sensitivity to locking out users of old LTS
lines, vs. being able to use features of, and test against, the latest
upstream software. WF 1.4.2 + Jenkins 1.580.1 is the most conservative
choice.

> 2. Should I extend AbstractSynchronousNonBlockingStepExecution or
> AbstractStepExecutionImpl?

If you are indeed using WF 1.10+ with
`AbstractSynchronousNonBlockingStepExecution` available, use it in
preference to `AbstractSynchronousStepExecution` in most cases.

> I'm not sure the clearly understand the impact of
> synchronous and asynchronous executions on the workflow engine. An example
> of AbstractStepExecutionImpl implementation would be greatly appreciated

So if you *are* writing a custom step, you would use the more general
`AbstractStepExecutionImpl` if your step needs to initiate some
process, then wait (say, for an external service to call you back),
then do something else later. You would also use it if your step
`takesImplicitBlockArgument` (so invoked with a `{…}` closure). If the
step just does something and exits as soon as it can, it is a
synchronous step.

> 3. Should I upgrade the Builder subclass to implement the SimpleBuildStep
> interface?

That is the easiest approach to compatibility. There is no need for
any Workflow APIs at all. Your builder will behave exactly as it does
in a freestyle build. You get less flexibility this way: for example,
you lose the option of running the build step outside of a `node {}`
block, even if it does not actually need a slave/workspace.

domi

unread,
Sep 16, 2015, 1:07:10 AM9/16/15
to jenkin...@googlegroups.com
These are some really good hints, they should be added to the workflow documentation
Domi
> --
> 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 jenkinsci-de...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr3qzE5AbOs-gY%2B9etdPSA%2Bb5GZhf1CyPLiyPu4MCYKqZQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages