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

NoStaplerConstructorException on UserMergeOptions.mergeStrategy

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • git-plugin
    • Jenkins 1.642.3, Pipeline 2.0, Git Plugin 2.4.4, Git Client Plugin 1.19.6

      Using Jenkins 1.642.3 and Pipeline 2.0, an exception is thrown when the DataBoundConstructor is missing from plugin code. The problem can be reproduced with the following line up: Jenkins 1.642.3, Pipeline 2.0, Git Plugin 2.4.4, Git Client Plugin 1.19.6.

      The problem did not exists with Pipeline 1.15 and Jenkins 1.642.1.

      To reproduce the problem, install those plugins, create a Pipeline job, and go in the snippet generator, then:

      • select the "checkout" step
      • select Git
      • Additional behaviors: Merge Before Build
      • Click "Generate Groovy"

      The stacktrace in the console should contain:

      Caused by: org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of class org.jenkinsci.plugins.gitclient.MergeCommand$Strategy
      

      And there is no groovy code generated.

          [JENKINS-34070] NoStaplerConstructorException on UserMergeOptions.mergeStrategy

          Martin d'Anjou created issue -
          Jesse Glick made changes -
          Priority Original: Minor [ 4 ] New: Critical [ 2 ]
          Jesse Glick made changes -
          Labels New: regression

          Jesse Glick added a comment -

          Presumably a regression from the move from DescribableHelper to DescribableModel.

          Jesse Glick added a comment - Presumably a regression from the move from DescribableHelper to DescribableModel .
          Jesse Glick made changes -
          Summary Original: Pipeline 2.0 causes snippet generator to throw exception when DataBoundConstructor is missing New: Pipeline 2.0 causes snippet generator to throw exception when dealing with enums

          Jesse Glick added a comment -

          Not sure offhand what caused this to regress but it is clear from looking at the code in the Git plugin what is wrong; perhaps it just worked by accident before. UserMergeOptions has conflicting types for the mergeStrategy parameter: as a String in the @DataBoundConstructor, but as an Enum (MergeCommand.Strategy) in the matching getter.

          It must use a single consistent type for both. Best would be to use the enum in both (ideally taking the opportunity to switch to @DataBoundSetter for the optional parameters). fastForwardMode is already done this way, so following suit would allow DescriptorImpl.doFillMergeStrategyItems to be deleted in favor of f:enum in the config.jelly.

          Ironically, it seems to be you who added the new field with the proper usage style in JENKINS-12402, without fixing the definition of the existing field.

          As an aside, the two id attributes in the config.jelly are unnecessary and should be deleted.

          Jesse Glick added a comment - Not sure offhand what caused this to regress but it is clear from looking at the code in the Git plugin what is wrong ; perhaps it just worked by accident before. UserMergeOptions has conflicting types for the mergeStrategy parameter: as a String in the @DataBoundConstructor , but as an Enum ( MergeCommand.Strategy ) in the matching getter. It must use a single consistent type for both. Best would be to use the enum in both (ideally taking the opportunity to switch to @DataBoundSetter for the optional parameters). fastForwardMode is already done this way, so following suit would allow DescriptorImpl.doFillMergeStrategyItems to be deleted in favor of f:enum in the config.jelly . Ironically, it seems to be you who added the new field with the proper usage style in JENKINS-12402 , without fixing the definition of the existing field. As an aside, the two id attributes in the config.jelly are unnecessary and should be deleted.
          Jesse Glick made changes -
          Component/s New: git-plugin [ 15543 ]
          Component/s Original: workflow-plugin [ 18820 ]
          Labels Original: regression New: regression workflow
          Priority Original: Critical [ 2 ] New: Major [ 3 ]
          Summary Original: Pipeline 2.0 causes snippet generator to throw exception when dealing with enums New: NoStaplerConstructorException on UserMergeOptions.mergeStrategy
          Jesse Glick made changes -
          Link New: This issue is related to JENKINS-31925 [ JENKINS-31925 ]
          Jesse Glick made changes -
          Remote Link New: This issue links to "structs PR 4 (Web Link)" [ 14172 ]
          Martin d'Anjou made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]

            jglick Jesse Glick
            deepchip Martin d'Anjou
            Votes:
            5 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: