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

email-ext fails when CasC attempts to set smtpHost

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      The descriptor throws an error when you attempt to set a value for smtpHost using jcasc plugin.

       

      The error message is identical to this reported github issue and subsequently JENKINS-53467 for the Mailer plugin which was fixed by introducing a getSmtpHost() method. It appears the solution for this plugin may not be as trivial however; I noticed a getSmtpHost() method is already present in MailAccount.java .

       

      SEVERE: Failed ConfigurationAsCode.init
      java.lang.Error: java.lang.reflect.InvocationTargetException
      at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:110)
      at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:175)
      at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
      at jenkins.model.Jenkins$5.runTask(Jenkins.java:1068)
      at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
      at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)
      Caused by: java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:104)
      ... 8 more
      Caused by: io.jenkins.plugins.casc.ConfiguratorException: unclassified: error configuring 'unclassified' with class io.jenkins.plugins.casc.impl.configurators.GlobalConfigurationCategoryConfigurator configurator
      at io.jenkins.plugins.casc.ConfigurationAsCode.invokeWith(ConfigurationAsCode.java:611)
      at io.jenkins.plugins.casc.ConfigurationAsCode.checkWith(ConfigurationAsCode.java:640)
      at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:627)
      at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:539)
      at io.jenkins.plugins.casc.ConfigurationAsCode.configure(ConfigurationAsCode.java:270)
      at io.jenkins.plugins.casc.ConfigurationAsCode.init(ConfigurationAsCode.java:262)
      ... 13 more
      Caused by: io.jenkins.plugins.casc.ConfiguratorException: Invalid configuration elements for type class hudson.plugins.emailext.ExtendedEmailPublisherDescriptor : smtpHost
      at io.jenkins.plugins.casc.BaseConfigurator.handleUnknown(BaseConfigurator.java:355)
      at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:345)
      at io.jenkins.plugins.casc.BaseConfigurator.check(BaseConfigurator.java:265)
      at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:330)
      at io.jenkins.plugins.casc.BaseConfigurator.check(BaseConfigurator.java:265)
      at io.jenkins.plugins.casc.ConfigurationAsCode.lambda$checkWith$8(ConfigurationAsCode.java:640)
      at io.jenkins.plugins.casc.ConfigurationAsCode.invokeWith(ConfigurationAsCode.java:605)
      ... 18 more

        Attachments

          Activity

          Hide
          metux Enrico Weigelt added a comment -

          Did you check whether the setter is also present ?

          In my case (w/ plugin-mailer) only the getter was missing, but maybe here's the opposite case.

          IMHO, casc needs both.

          Show
          metux Enrico Weigelt added a comment - Did you check whether the setter is also present ? In my case (w/ plugin-mailer) only the getter was missing, but maybe here's the opposite case. IMHO, casc needs both.
          Hide
          slide_o_mix Alex Earl added a comment -

          There is a lot of custom JSON reading in the configure method of the descriptor, so I think there are a lot of changes needed in the plugin.

          Show
          slide_o_mix Alex Earl added a comment - There is a lot of custom JSON reading in the configure method of the descriptor, so I think there are a lot of changes needed in the plugin.
          Hide
          benfiedler Ben Fiedler added a comment - - edited

          You are probably right; these are the fields in the extendedemailpublisher descriptor I have successfully configured using jcasc:

          charset, defaultBody, defaultContentType, defaultSubject, defaultReplyTo, smtpPort, and watchingEnabled.

          Oddly the smtpHost is the only value that throws an error.

           

          For now, as a workaround I am making a groovyscript and sticking it into jenkins init.groovy.d/ which loads the descriptor and then directly modifies the smtpHost member.

           

          Show
          benfiedler Ben Fiedler added a comment - - edited You are probably right; these are the fields in the extendedemailpublisher descriptor I have successfully configured using jcasc: charset, defaultBody, defaultContentType, defaultSubject, defaultReplyTo, smtpPort, and watchingEnabled. Oddly the smtpHost is the only value that throws an error.   For now, as a workaround I am making a groovyscript and sticking it into jenkins init.groovy.d/ which loads the descriptor and then directly modifies the smtpHost member.  
          Hide
          slide_o_mix Alex Earl added a comment -

          Can you try using smtpServer instead?

          Show
          slide_o_mix Alex Earl added a comment - Can you try using smtpServer instead?
          Hide
          benfiedler Ben Fiedler added a comment - - edited

          Well this is embarrassing. I was sure I had originally tried smtpServer (the name that actually shows up extended descriptor) in jcasc unsuccessfully (getting a generic null error or something similar), but trying again with it just now and it works with no problem.

          Maybe I accidentally tried it with the mailer plugin, or coincidentally had some other problem with my yaml at the time.

          I will mark this is closed

          Show
          benfiedler Ben Fiedler added a comment - - edited Well this is embarrassing. I was sure I had originally tried smtpServer (the name that actually shows up extended descriptor) in jcasc unsuccessfully (getting a generic null error or something similar), but trying again with it just now and it works with no problem. Maybe I accidentally tried it with the mailer plugin, or coincidentally had some other problem with my yaml at the time. I will mark this is closed
          Hide
          benfiedler Ben Fiedler added a comment -

          User error

          Show
          benfiedler Ben Fiedler added a comment - User error

            People

            • Assignee:
              davidvanlaatum David van Laatum
              Reporter:
              benfiedler Ben Fiedler
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: