Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-70728

Steps can't be with a body and without one at the same time

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • workflow-cps-plugin
    • None

      When developing a step which can both have a body or doesn't (eg a meta step of sorts), it is impossible to define a correct descriptor:

      When defining with takesImplicitBlockArgument() = false, you obviously can't accept a body, but when defining with takesImplicitBlockArgument() = true, you get:

       

      java.lang.IllegalStateException: stepName step must be called with a body

       

      Yet, the documentation states:

      Return true if this step can accept an implicit block argument. (If it can, but it is called without a block, StepContext.hasBody() will be false.) 

      Eg per documentation the implicit block argument is NOT mandatory when defined as true. Yet it is still required by the code.

      Running the step with an empty body as:

      stepName {}
      

      is kinda a workaround for such a case, but kinda clunky.

       

            Unassigned Unassigned
            evengard Evengard
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: