• Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • groovy-plugin
    • None
    • All

      DescriptorImpl.newInstance() is deprecated since a while and @DataBoundConstructor should be used instead.

      Builders not having a @DataBoundConstructor can't be used within Extensions (e.g. BuildWrappers) a using @DataBoundConstructor itself.
      Please add a @DataBoundConstructor to

      • hudson.plugins.groovy.Groovy
        and
      • hudson.plugins.groovy.ScriptSource

      Caused by: java.lang.IllegalArgumentException: Failed to instantiate class hudson.plugins.groovy.Groovy from {"groovyName":"(Default)","kind":"hudson.plugins.groovy.Groovy$DescriptorImpl","parameters":"","properties":"","scriptParameters":"","scriptSource":

      {"scriptFile":"dummy.groovy","value":"0"}

      ,"stapler-class":"hudson.plugins.groovy.Groovy"}
      at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:352)
      at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:552)
      at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:587)
      at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:344)
      ... 40 more
      Caused by: org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of class hudson.plugins.groovy.Groovy
      at org.kohsuke.stapler.RequestImpl.loadConstructorParamNames(RequestImpl.java:461)
      at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:331)

      Caused by: java.lang.IllegalArgumentException: Failed to convert the scriptSource parameter of the constructor public hudson.plugins.groovy.SystemGroovy(hudson.plugins.groovy.ScriptSource,java.lang.String,java.lang.String)
      at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:346)
      ... 43 more
      Caused by: java.lang.IllegalArgumentException: Failed to instantiate interface hudson.plugins.groovy.ScriptSource from

      {"command":"println(\"hello\")","value":"1"}

      at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:352)
      at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:552)
      at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:344)
      ... 43 more
      Caused by: org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of interface hudson.plugins.groovy.ScriptSource
      at org.kohsuke.stapler.RequestImpl.loadConstructorParamNames(RequestImpl.java:461)
      at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:331)

      The same already had to be done for 'hudson.tasks.Shell' in the core - see http://hudson.361315.n4.nabble.com/DataBoundConstructor-td2244199.html

          [JENKINS-6797] Add @DataBoundConstructor

          vjuranek added a comment -

          Hi, when this is happening or how can I reproduce this issue? Thanks

          vjuranek added a comment - Hi, when this is happening or how can I reproduce this issue? Thanks

          This can be reproduced when appling this http://issues.jenkins-ci.org/browse/JENKINS-6601 patch to the m2release plugin.
          And then trying to create a maven2 job with additonal pre or post (groovy) steps.
          My request for your change is actualy to fully enable the patch in the m2release plugin.
          Without your change it will not by possible to use the groovy steps as pre or post steps.

          Dominik Bartholdi added a comment - This can be reproduced when appling this http://issues.jenkins-ci.org/browse/JENKINS-6601 patch to the m2release plugin. And then trying to create a maven2 job with additonal pre or post (groovy) steps. My request for your change is actualy to fully enable the patch in the m2release plugin. Without your change it will not by possible to use the groovy steps as pre or post steps.

          Quote from a mail I received from vjuranek:

          Hi,

          > I've spent a few hours looking at the source and can see that the
          > @DataBoundConstructor annotations are in the classes that implement the
          > interface that the stack trace complains about.

          the problem is that Stapler tries to instantite interface (ScriptSource)
          itself

          > Can you give me some advice on how I can patch the code to resolve the
          > issue?

          unfortunatelly no, I looked on it little bit yesterday and it seems to me,
          that there's not simple way how to fix it. I think there are two options: patch
          the Stapler to be able to deal with interfaces or rewrite the Groovy plugin
          not to use interface or abstract class for ScriptSource. Rewriting the Groovy
          plugin is probably more easy way to go, the only problem here is to keep
          backward compatibility.

          I'd like to look on it more carefully in near future, but cannot promise when
          it will be. If you want to patch the plugin, I would suggest to ask on Jenkins
          dev list first if there is some way how Stapler can deal with interfaces -
          maybe I missed something and there is a simple solution for this problem.

          Cheers
          Vojtech

          Bernard McKeever added a comment - Quote from a mail I received from vjuranek: Hi, > I've spent a few hours looking at the source and can see that the > @DataBoundConstructor annotations are in the classes that implement the > interface that the stack trace complains about. the problem is that Stapler tries to instantite interface (ScriptSource) itself > Can you give me some advice on how I can patch the code to resolve the > issue? unfortunatelly no, I looked on it little bit yesterday and it seems to me, that there's not simple way how to fix it. I think there are two options: patch the Stapler to be able to deal with interfaces or rewrite the Groovy plugin not to use interface or abstract class for ScriptSource. Rewriting the Groovy plugin is probably more easy way to go, the only problem here is to keep backward compatibility. I'd like to look on it more carefully in near future, but cannot promise when it will be. If you want to patch the plugin, I would suggest to ask on Jenkins dev list first if there is some way how Stapler can deal with interfaces - maybe I missed something and there is a simple solution for this problem. Cheers Vojtech

          Dave Carey added a comment - - edited

          Am I right in concluding that any Groovy Script or Command is off-limits as a pre-build step until this issue is resolved?

          Cheers
          Dave

          Dave Carey added a comment - - edited Am I right in concluding that any Groovy Script or Command is off-limits as a pre-build step until this issue is resolved? Cheers Dave

          yes, that's right

          Dominik Bartholdi added a comment - yes, that's right

          any chance this gets fixed soon in the groovy plugin?

          Dominik Bartholdi added a comment - any chance this gets fixed soon in the groovy plugin?

          Andreas Katzig added a comment - - edited

          It would be great to see this fixed.

          Yet my current workaround is to use the "Groovy Postbuild Plugin" in combination with the "Flexible Publish Plugin" to achieve conditional execution of groovy scripts.

          Andreas Katzig added a comment - - edited It would be great to see this fixed. Yet my current workaround is to use the "Groovy Postbuild Plugin" in combination with the "Flexible Publish Plugin" to achieve conditional execution of groovy scripts.

          Tim Wood added a comment -

          Another vote for an expert to fix this issue, it also arises using a Groovy step with Conditional Build Step plugin (J-15833).

          Tim Wood added a comment - Another vote for an expert to fix this issue, it also arises using a Groovy step with Conditional Build Step plugin (J-15833).

          Code changed in jenkins
          User: Stefan Wolf
          Path:
          src/main/resources/hudson/plugins/groovy/Groovy/config.jelly
          src/main/resources/hudson/plugins/groovy/SystemGroovy/config.jelly
          src/main/resources/hudson/plugins/groovy/form/multi-hetero-radio.jelly
          src/main/resources/hudson/plugins/groovy/form/taglib
          http://jenkins-ci.org/commit/groovy-plugin/68fb0018f602d55e04a332e240489b07888861f6
          Log:
          [FIXED JENKINS-6797] Made a patched copy of hetero-radio to fix issues with closed radio details.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Stefan Wolf Path: src/main/resources/hudson/plugins/groovy/Groovy/config.jelly src/main/resources/hudson/plugins/groovy/SystemGroovy/config.jelly src/main/resources/hudson/plugins/groovy/form/multi-hetero-radio.jelly src/main/resources/hudson/plugins/groovy/form/taglib http://jenkins-ci.org/commit/groovy-plugin/68fb0018f602d55e04a332e240489b07888861f6 Log: [FIXED JENKINS-6797] Made a patched copy of hetero-radio to fix issues with closed radio details.

            lvotypkova Lucie Votypkova
            domi Dominik Bartholdi
            Votes:
            7 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: