Hi Jesse,

thanks for the quick response!

On Tue, Mar 05, 2019 at 02:21:03PM -0500, Jesse Glick wrote:
> On Tue, Mar 5, 2019 at 1:07 PM <[email protected]> wrote:
> > The step can be used with our without a body
> 
> Huh? That is not possible. I given `StepDescriptor` specifies whether
> it `takesImplicitBlockArgument` or not. If you want two syntaxes, you
> need two step names.

I think it is:

>From the docs of StepDescriptor:

/**
 * Return true if this step can accept an implicit block argument.
 * (If it can, but it is called without a block, {@link StepContext#hasBody} 
will be false.)
 * @see StepContext#newBodyInvoker()
 */

Also official steps like "stage" accept both forms.
(Yes, the form without step is deprecated, but for other reasons)

Also this part of the plugin already works quite well.

>> # applies the config to the current block
> There is no such concept in Pipeline.

To be more precise it refers to the datastructure associated with
the current FlowNode.
(I can elaborate on the specifics if wanted)

>> I would like to increase the ergonomics of the syntax
>>
>> # desired syntax
>> stage("s") {
>>     foo.setting = 1
>
> This is not possible using steps.
>
>> implement it with a global variable
>
> As noted in the `GlobalVariable` Javadoc, you should avoid this API.

Yes, I would like to avoid it.

OTOH I don't think it is *that* bad in case of this specific plugin:

* The plugin is *very* generic.
  (it only looks at the build as a series of nodes/steps, without any
  assumptions about their content)
* It does not have to be compatible with declarative pipeline.
  (It would be better for its ergonomics to implement a dedicated
  extensionpoint for declarative pipelines)
* The variable is only syntactic sugar that is meant to save two braces in Cps
  pipelines.
* The groovy code it executes is literally:

  public Object getValue(@Nonnull CpsScript script) throws Exception {
      return script.evaluate("steps.foo()");
  }

>> Do you think this functionality would be in scope of Jenkins?
>
> No. I would stick to the block-scoped step and leave it at that.

What do you think of having steps (optionally, decided by the step author)
available as something like global variables?
This would allow plugin authors to provide this functionality
(for which they currently do implement GlobalVariables)
without the disadvantages and without a tight dependency on Cps.

Thanks,
Thomas

-- 
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/20190306085912.GA6280%40fralrnd0033.fra.amadeus.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to