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

Add @DataBoundConstructor

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: groovy-plugin
    • Labels:
      None
    • Environment:
      All
    • Similar Issues:

      Description

      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

        Attachments

          Issue Links

            Activity

            Hide
            domi Dominik Bartholdi added a comment -

            yes, that's right

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

            any chance this gets fixed soon in the groovy plugin?

            Show
            domi Dominik Bartholdi added a comment - any chance this gets fixed soon in the groovy plugin?
            Hide
            derfunk 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.

            Show
            derfunk 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.
            Hide
            timwood0 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).

            Show
            timwood0 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).
            Hide
            scm_issue_link 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.

            Show
            scm_issue_link 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.

              People

              • Assignee:
                lvotypkova Lucie Votypkova
                Reporter:
                domi Dominik Bartholdi
              • Votes:
                7 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: