[workflow] can a Step create child Steps?

41 views
Skip to first unread message

James Strachan

unread,
Jul 24, 2015, 12:00:41 PM7/24/15
to Jenkins Developers
I've dipped my toe into the world of writing Jenkins Workflow Steps; so far so good!

I've written a little hubot chat bot approval step as a kinda facade/decorator of InputStep:

whats a bit smelly though is that the hubotApprove should really configure and execute an `input` step internally

right now I've been writing a redundant 2nd line in the workflow groovy files:

hubotApprove "Do you want to stage?"
input id: 'Proceed', message: "Do you want to stage?"

When really the HubotApproveStep should be creating the InputStep / InputStepExecution internally so the user just needs to do:

hubotApprove "Do you want to stage?"
 
I wonder has anyone ever tried such a thing; written a Step which creates one or more child steps itself? I wasn't sure how the DI stuff worked for that kinda thing and so far my googling / searching hasn't found an example. 

Anyone got any hints please?

Many thanks!

James

Jesse Glick

unread,
Jul 27, 2015, 2:52:29 PM7/27/15
to Jenkins Dev
On Fri, Jul 24, 2015 at 12:00 PM, James Strachan
<james.s...@gmail.com> wrote:
> I wonder has anyone ever tried such a thing; written a Step which creates
> one or more child steps itself?

There is no API which would permit a `StepExecution` to create and run
another one.

What you *can* do is to create a `Step` which does just the Hubot
notification itself, then create a higher-level DSL that calls it
together with `input` in a recommended way. `docker-workflow` does
something like this.
Reply all
Reply to author
Forward
0 new messages