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

Missing TestResultColumn() constructor

    Details

    • Similar Issues:

      Description

      Hi,

      I need to programmatically create some sectioned views (via groovy script to ease maintenance of hundreds of jobs on multiple projects/teams/views)
      I was previously using version 1.2 of the plugin with an old version of Jenkins. All was OK.

      Since we migrated to Jenkins 1.509.2 + plugin 1.10 my script doesn't work any more because of:
      "Failed to instantiate class jenkins.plugins.extracolumns.TestResultColumn from null"

      Looking at:
      hudson.model.Descriptor.newInstance(StaplerRequest req, JSONObject formData)
      showed it "return verifyNewInstance(clazz.newInstance());" where clazz is jenkins.plugins.extracolumns.TestResultColumn and can't instantiate a new instance as there is only one constructor that needs an int in parameter.

      It would be handy to add a no param constructor that set the int to a default value to be able to run column creation through their Descriptor and not have to add a specific case for TestResultColumn.

      This is a snippet of my groovy script:

      import hudson.DescriptorExtensionList
      import hudson.model.*
      import hudson.model.Descriptor.FormException
      import hudson.plugins.sectioned_view.*
      import hudson.util.*
      import hudson.views.*
      
      DEFAULT_COLUMNS = [
              BuildButtonColumn.class                                                 // OK
              ,com.robestone.hudson.compactcolumns.JobNameColumn.class                // OK
              ,LastDurationColumn.class                                               // OK
              ,jenkins.plugins.extracolumns.TestResultColumn.class                    // NOK
          ]
      
      println("Init our columns ...")
      myColumns = [];
      DescriptorExtensionList<ListViewColumn, Descriptor<ListViewColumn>> all = ListViewColumn.all();
      
      for (Class<? extends ListViewColumn> d: DEFAULT_COLUMNS) {
          Descriptor<ListViewColumn> des = all.find(d);
          if (des  != null) {
              println("Case " + d)
              switch(d) {
                  case jenkins.plugins.extracolumns.TestResultColumn.class:
                      println("descriptor = " + des)
                      println("descriptor.clazz = " + des.clazz)
                      println()
                      try {
                          clazzInst = d.newInstance()
                          println("+++Successfully run TestResultColumn.newInstance() = " + clazzInst)
                          myColumns.add(clazzInst);
                      } catch (Exception exp) {
                          println("!!!Exception while instantiating new TestResultColumn(): " + exp.getMessage())
                      }
                      try {
                          clazzInst0 = d.newInstance(0)
                          println("+++Successfully run new TestResultColumn.newInstance(0) = " + clazzInst0)
                          myColumns.add(clazzInst0);
                      } catch (Exception exp) {
                          println("!!!Exception while instantiating new TestResultColumn(0): " + exp.getMessage())
                      }
                      try {
                          tmp = des.newInstance(null,null)
                          myColumns.add(tmp);
                          println("+++Successfully run TestResultColumn.DescriptorImpl.newInstance(null, null) = " + tmp)
                      } catch (Error exp) {
                          println("!!!Error while TestResultColumn.DescriptorImpl.newInstance(null, null): " + exp.getMessage())
                      }
                  break
                  default:
                      myColumns.add(des.newInstance(null, null));
                  break
              }
          }
          else
          {
              println("No descriptior found for " + d)
          }
      }
      
      println("\nResulting columns ...")
      myColumns.each {println(it)}
      

      Give me your thoughts. Maybe there is another way to do this!

      Cheers,

      Greg

        Attachments

          Activity

          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Fred G
          Path:
          src/main/java/jenkins/plugins/extracolumns/ConfigureProjectColumn.java
          src/main/java/jenkins/plugins/extracolumns/DescriptionColumn.java
          src/main/java/jenkins/plugins/extracolumns/DisableProjectColumn.java
          src/main/java/jenkins/plugins/extracolumns/LastBuildConsoleColumn.java
          src/main/java/jenkins/plugins/extracolumns/TestResultColumn.java
          http://jenkins-ci.org/commit/extra-columns-plugin/15c3a251d5fbcc79e6c4d6e1d6b36745a0728eb4
          Log:
          [FIXED JENKINS-18930] Missing TestResultColumn() constructor

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Fred G Path: src/main/java/jenkins/plugins/extracolumns/ConfigureProjectColumn.java src/main/java/jenkins/plugins/extracolumns/DescriptionColumn.java src/main/java/jenkins/plugins/extracolumns/DisableProjectColumn.java src/main/java/jenkins/plugins/extracolumns/LastBuildConsoleColumn.java src/main/java/jenkins/plugins/extracolumns/TestResultColumn.java http://jenkins-ci.org/commit/extra-columns-plugin/15c3a251d5fbcc79e6c4d6e1d6b36745a0728eb4 Log: [FIXED JENKINS-18930] Missing TestResultColumn() constructor
          Hide
          fredg Fred G added a comment -

          Here is a test version that contains the fix:
          https://jenkins.ci.cloudbees.com/job/plugins/job/extra-columns-plugin/ws/target/extra-columns.hpi

          Can you confirm that it works?

          Show
          fredg Fred G added a comment - Here is a test version that contains the fix: https://jenkins.ci.cloudbees.com/job/plugins/job/extra-columns-plugin/ws/target/extra-columns.hpi Can you confirm that it works?
          Hide
          gnion Greg Nion added a comment -

          Hi Fred,

          thanks for your prompt response.
          I'll test it as soon as I setup a dev instance of my Jenkins

          Cheers,

          Greg

          Show
          gnion Greg Nion added a comment - Hi Fred, thanks for your prompt response. I'll test it as soon as I setup a dev instance of my Jenkins Cheers, Greg
          Hide
          gnion Greg Nion added a comment -

          tested successfully!
          Waiting for your delivery.
          Thanks a lot.

          Show
          gnion Greg Nion added a comment - tested successfully! Waiting for your delivery. Thanks a lot.
          Hide
          fredg Fred G added a comment -

          Released in version 1.11.

          Show
          fredg Fred G added a comment - Released in version 1.11.

            People

            • Assignee:
              fredg Fred G
              Reporter:
              gnion Greg Nion
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: