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

      When trying to generate a parallel step from the snippet generator an exception is thrown:

      java.lang.RuntimeException: Failed to instantiate class org.jenkinsci.plugins.workflow.cps.steps.ParallelStep from {"stapler-class":"org.jenkinsci.plugins.workflow.cps.steps.ParallelStep", "$class":"org.jenkinsci.plugins.workflow.cps.steps.ParallelStep"}
      	at hudson.model.Descriptor.newInstance(Descriptor.java:579)
      	at org.jenkinsci.plugins.workflow.cps.Snippetizer.doGenerateSnippet(Snippetizer.java:212)
      
      ...
      
      Caused by: org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of class org.jenkinsci.plugins.workflow.cps.steps.ParallelStep
      	at org.kohsuke.stapler.ClassDescriptor.loadConstructorParamNames(ClassDescriptor.java:177)
      

          [JENKINS-30572] Parallel step snippet generator error

          This is what I see in the snippet generator help text:

          (No visual configuration.) Takes a map from branch names to closures 
          and an optional argument failFast which will terminate all branches upon a failure in any other branch:
          
          parallel firstBranch: {
              // do something
          }, secondBranch: {
              // do something else
          },
          failFast: true|false
          

          IMO it's not clear that the snippet generator will fail. If this is an accepted behaviour, I will note it clearly in the help text (as I'm currently working on JENKINS-30086).

          Antonio Muñiz added a comment - This is what I see in the snippet generator help text: (No visual configuration.) Takes a map from branch names to closures and an optional argument failFast which will terminate all branches upon a failure in any other branch: parallel firstBranch: { // do something }, secondBranch: { // do something else }, failFast: true|false IMO it's not clear that the snippet generator will fail. If this is an accepted behaviour, I will note it clearly in the help text (as I'm currently working on JENKINS-30086 ).

          Jesse Glick added a comment -

          No visual configuration.

          is what I meant, but yes it could be better explained.

          ParallelStep.DescriptorImpl could override newInstance(StaplerRequest, JSONObject) to return some sample ParallelStep with no branches, but this is not very helpful. Might be better for this to throw something (UnsupportedOperationException?) that would be rendered more politely in the result textarea, or even for StepDescriptor to be allowed to state that it has no visual configuration and to simply disable the snippet generation button in that case.

          Jesse Glick added a comment - No visual configuration. is what I meant, but yes it could be better explained. ParallelStep.DescriptorImpl could override newInstance(StaplerRequest, JSONObject) to return some sample ParallelStep with no branches, but this is not very helpful. Might be better for this to throw something ( UnsupportedOperationException ?) that would be rendered more politely in the result textarea, or even for StepDescriptor to be allowed to state that it has no visual configuration and to simply disable the snippet generation button in that case.

          pipeline-syntax/html shows this error instead of documentation.

          Kanstantsin Shautsou added a comment - pipeline-syntax/html shows this error instead of documentation.

          Sean Flanigan added a comment -

          This also affects GDSL files generated by Jenkins:

          // Errors on:
          // class org.jenkinsci.plugins.workflow.cps.steps.ParallelStep: There's no @DataBoundConstructor on any constructor of class org.jenkinsci.plugins.workflow.cps.steps.ParallelStep
          

          Sean Flanigan added a comment - This also affects GDSL files generated by Jenkins: // Errors on: // class org.jenkinsci.plugins.workflow.cps.steps.ParallelStep: There's no @DataBoundConstructor on any constructor of class org.jenkinsci.plugins.workflow.cps.steps.ParallelStep

          Daniel Beck added a comment -

          Daniel Beck added a comment - Also affects https://jenkins.io/doc/pipeline/steps/workflow-cps/#parallel-execute-in-parallel

          Oleg Nenashev added a comment -

          The issue still exists on the latest versions

          Oleg Nenashev added a comment - The issue still exists on the latest versions

          Ernst de Haan added a comment -

           Is there a workaround available so that I can have syntax highlighting in IntelliJ IDEA?

          I tried this:

          method(name: 'parallel', type: 'Object', params: [name: 'steps', type: 'Map'], doc: 'Parallel steps')
          

          …but that doesn't work. I may need to specify a different type (but which one?)

          Ernst de Haan added a comment -  Is there a workaround available so that I can have syntax highlighting in IntelliJ IDEA? I tried this: method(name: 'parallel', type: 'Object', params: [name: 'steps', type: 'Map'], doc: 'Parallel steps') …but that doesn't work. I may need to specify a different type (but which one?)

          Trevor Gray added a comment -

           I added the following lines to the GDSL and it seems to be working, using Intellij IDEA (2017.2.5):

          method(name: 'parallel', type: 'Object', params: [steps: 'Map'], doc: 'Execute in parallel')
          method(name: 'parallel', type: 'Object', params: [steps: 'Map', failFast: 'boolean'], doc: 'Execute in parallel')

           

          Another workaround, is to just disable the check by adding the following comment above each call to parallel:

          //noinspection GroovyAssignabilityCheck

          But this is really just ignoring the issue, and unhelpful for autocomplete / syntax highlighting.

          Trevor Gray added a comment -  I added the following lines to the GDSL and it seems to be working, using Intellij IDEA (2017.2.5): method(name: 'parallel' , type: ' Object ' , params: [steps: 'Map' ], doc: 'Execute in parallel' ) method(name: 'parallel' , type: ' Object ' , params: [steps: 'Map' , failFast: ' boolean ' ], doc: 'Execute in parallel' )   Another workaround, is to just disable the check by adding the following comment above each call to parallel : //noinspection GroovyAssignabilityCheck But this is really just ignoring the issue, and unhelpful for autocomplete / syntax highlighting.

          Devin Nusbaum added a comment -

          I filed a PR to fix the GDSL issue here. The snippet generator and automatically generated documentation would not be affected by that PR.

          Devin Nusbaum added a comment - I filed a PR to fix the GDSL issue here . The snippet generator and automatically generated documentation would not be affected by that PR.

          Devin Nusbaum added a comment -

          Ok, the GDSL issues should be fixed in Pipeline: Groovy Plugin version 2.73. The documentation issues and error when "generate snippet" is clicked still exist, and I'm not sure of a good way to fix them without more special casing for the parallel step. I'm going to move this back to open.

          Devin Nusbaum added a comment - Ok, the GDSL issues should be fixed in Pipeline: Groovy Plugin version 2.73. The documentation issues and error when "generate snippet" is clicked still exist, and I'm not sure of a good way to fix them without more special casing for the parallel step. I'm going to move this back to open.

            Unassigned Unassigned
            amuniz Antonio Muñiz
            Votes:
            4 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated: