Improved StepExecutions
, available outside test scope
#149
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I found myself using the
StepExecutions
utility a lot in jenkinsci/workflow-cps-plugin#834 but there were some limitations that made it awkward:return null;
even for synchronous steps which were not designed to return a value (the most common case), forcing use of a block-form lambda even for bodies consisting of a single statement.Serializable
made for some awkward idioms. This was never productive since the body is used only inStepExecution.start
, so even if the execution gets serialized, there is never a reason to deserialize the body.After making those improvements I realized that the utility could actually be useful for production code, so opening it up outside of test scope. (Not helpful for existing steps since these need to retain serial form compatibility of the
StepExecution
implementation, except perhaps in the case ofSynchronousStepExecution
s.)