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

email-ext plugin causes NullPointerException when sending email for successful build

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • email-ext-plugin
    • None
    • Platform: All, OS: Linux

      I have Hudson 1.146 and email-ext 1.2 installed. I previously had email
      notifications working for my job using the email config provided by Hudson.

      I configured the email-ext plugin to send emails on successful builds, but an
      NPE is thrown in the hudson.Util.encode() method when it attempts to send the email.

      I tried this with the option for "E-mail Notification" checked and with it
      unchecked, and the NPE occurred for both scenarios.

      Here is the output from my job ( the email address was xxx'ed out )

      ---------------------

      BUILD SUCCESSFUL
      Total time: 2 minutes 25 seconds
      Recording fingerprints
      Recording test results
      Sending e-mails to: xxx@xxx.com
      FATAL: null
      java.lang.NullPointerException
      at hudson.Util.encode(Util.java:400)
      at
      hudson.plugins.emailext.ExtendedEmailPublisher.transformText(ExtendedEmailPublisher.java:244)
      at
      hudson.plugins.emailext.ExtendedEmailPublisher.createMail(ExtendedEmailPublisher.java:195)
      at
      hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:167)
      at
      hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:155)
      at
      hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:124)
      at hudson.model.Build$RunnerImpl.post2(Build.java:138)
      at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:244)
      at hudson.model.Run.run(Run.java:597)
      at hudson.model.Build.run(Build.java:103)
      at hudson.model.ResourceController.execute(ResourceController.java:66)
      at hudson.model.Executor.run(Executor.java:62)

          [JENKINS-1144] email-ext plugin causes NullPointerException when sending email for successful build

          nharward added a comment -

          I'd like to chime in here as well, though I have a different stacktrace. I'm
          running Hudson 1.261 and email-ext version 2.1. I tried with an empty global
          list but specifying per-trigger email address, only using the global list,
          both... same result. The job I have running just calls /bin/true and nothing
          else, here is the console output:

          started
          [workspace] $ /bin/sh -xe /tmp/hudson30289.sh
          + /bin/true
          Email was triggered for: Success
          There are 1 triggered emails.
          Sending email for trigger: Success
          FATAL: null
          java.lang.NullPointerException
          at
          hudson.plugins.emailext.plugins.content.HudsonURLContent.getContent(HudsonURLContent.java:20)
          at
          hudson.plugins.emailext.ExtendedEmailPublisher.replaceTokensWithContent(ExtendedEmailPublisher.java:360)
          at
          hudson.plugins.emailext.ExtendedEmailPublisher.replaceTokensWithContent(ExtendedEmailPublisher.java:362)
          at
          hudson.plugins.emailext.ExtendedEmailPublisher.transformText(ExtendedEmailPublisher.java:340)
          at
          hudson.plugins.emailext.ExtendedEmailPublisher.createMail(ExtendedEmailPublisher.java:295)
          at
          hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:265)
          at
          hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:257)
          at
          hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:215)
          at
          hudson.model.AbstractBuild$AbstractRunner.performAllBuildStep(AbstractBuild.java:319)
          at
          hudson.model.AbstractBuild$AbstractRunner.performAllBuildStep(AbstractBuild.java:307)
          at hudson.model.Build$RunnerImpl.post2(Build.java:126)
          at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:292)
          at hudson.model.Run.run(Run.java:837)
          at hudson.model.Build.run(Build.java:88)
          at hudson.model.ResourceController.execute(ResourceController.java:70)
          at hudson.model.Executor.run(Executor.java:89)

          nharward added a comment - I'd like to chime in here as well, though I have a different stacktrace. I'm running Hudson 1.261 and email-ext version 2.1. I tried with an empty global list but specifying per-trigger email address, only using the global list, both... same result. The job I have running just calls /bin/true and nothing else, here is the console output: started [workspace] $ /bin/sh -xe /tmp/hudson30289.sh + /bin/true Email was triggered for: Success There are 1 triggered emails. Sending email for trigger: Success FATAL: null java.lang.NullPointerException at hudson.plugins.emailext.plugins.content.HudsonURLContent.getContent(HudsonURLContent.java:20) at hudson.plugins.emailext.ExtendedEmailPublisher.replaceTokensWithContent(ExtendedEmailPublisher.java:360) at hudson.plugins.emailext.ExtendedEmailPublisher.replaceTokensWithContent(ExtendedEmailPublisher.java:362) at hudson.plugins.emailext.ExtendedEmailPublisher.transformText(ExtendedEmailPublisher.java:340) at hudson.plugins.emailext.ExtendedEmailPublisher.createMail(ExtendedEmailPublisher.java:295) at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:265) at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:257) at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:215) at hudson.model.AbstractBuild$AbstractRunner.performAllBuildStep(AbstractBuild.java:319) at hudson.model.AbstractBuild$AbstractRunner.performAllBuildStep(AbstractBuild.java:307) at hudson.model.Build$RunnerImpl.post2(Build.java:126) at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:292) at hudson.model.Run.run(Run.java:837) at hudson.model.Build.run(Build.java:88) at hudson.model.ResourceController.execute(ResourceController.java:70) at hudson.model.Executor.run(Executor.java:89)

          nharward added a comment -

          Adding myself to the CC list, so I know when this fix will be in place.

          nharward added a comment - Adding myself to the CC list, so I know when this fix will be in place.

          againjj added a comment -

          The code regarding the first issue does not exist any more, so I assume it is
          fixed. The second issue has been fixed by Kohsuke, and is contained in release 2.2.

          againjj added a comment - The code regarding the first issue does not exist any more, so I assume it is fixed. The second issue has been fixed by Kohsuke, and is contained in release 2.2.

          nharward added a comment -

          I just tried release 2.2 and things work for me there. Thanks for the fix, it
          is appreciated

          nharward added a comment - I just tried release 2.2 and things work for me there. Thanks for the fix, it is appreciated

          Nitesh Shakya added a comment -

          I am using a new version of jenkins and still have similar issue. I am getting following errors:
          Sending email for trigger: Success
          ERROR: Could not send email as a part of the post-build publishers.
          java.lang.NullPointerException
          at java.util.regex.Matcher.quoteReplacement(Unknown Source)
          at hudson.plugins.emailext.plugins.ContentBuilder.transformText(ContentBuilder.java:65)
          at hudson.plugins.emailext.ExtendedEmailPublisher.setSubject(ExtendedEmailPublisher.java:453)
          at hudson.plugins.emailext.ExtendedEmailPublisher.createMail(ExtendedEmailPublisher.java:307)
          at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:255)
          at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:247)
          at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:207)
          at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36)
          at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:700)
          at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:675)
          at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:653)
          at hudson.model.Build$RunnerImpl.cleanUp(Build.java:171)
          at hudson.model.Run.run(Run.java:1453)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
          at hudson.model.ResourceController.execute(ResourceController.java:88)
          at hudson.model.Executor.run(Executor.java:238)
          Finished: SUCCESS

          I dont get an error when using test email

          Nitesh Shakya added a comment - I am using a new version of jenkins and still have similar issue. I am getting following errors: Sending email for trigger: Success ERROR: Could not send email as a part of the post-build publishers. java.lang.NullPointerException at java.util.regex.Matcher.quoteReplacement(Unknown Source) at hudson.plugins.emailext.plugins.ContentBuilder.transformText(ContentBuilder.java:65) at hudson.plugins.emailext.ExtendedEmailPublisher.setSubject(ExtendedEmailPublisher.java:453) at hudson.plugins.emailext.ExtendedEmailPublisher.createMail(ExtendedEmailPublisher.java:307) at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:255) at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:247) at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:207) at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36) at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:700) at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:675) at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:653) at hudson.model.Build$RunnerImpl.cleanUp(Build.java:171) at hudson.model.Run.run(Run.java:1453) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:238) Finished: SUCCESS I dont get an error when using test email

          Nitesh Shakya added a comment -

          I have following specification details
          Jenkins war org.jenkins-ci.main:jenkins-war:1.451
          Jenkins Email Extension Plugin This plugin is a replacement for Jenkins's email publisher
          2.18

          Sorry for not writing it in my previous comment

          Nitesh Shakya added a comment - I have following specification details Jenkins war org.jenkins-ci.main:jenkins-war:1.451 Jenkins Email Extension Plugin This plugin is a replacement for Jenkins's email publisher 2.18 Sorry for not writing it in my previous comment

          Nitesh Shakya added a comment -

          I am having similar issue again can you help me?

          Nitesh Shakya added a comment - I am having similar issue again can you help me?

          Code changed in jenkins
          User: slide
          Path:
          src/main/java/hudson/plugins/emailext/EmailExtensionPlugin.java
          src/main/java/hudson/plugins/emailext/EmailRecepientUtils.java
          src/main/java/hudson/plugins/emailext/EmailType.java
          src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java
          src/main/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptor.java
          src/main/java/hudson/plugins/emailext/plugins/ContentBuilder.java
          src/main/resources/hudson/plugins/emailext/ExtendedEmailPublisher/config.jelly
          src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherTest.java
          src/test/java/hudson/plugins/emailext/plugins/ContentBuilderTest.java
          http://jenkins-ci.org/commit/email-ext-plugin/09296a6d5e321ea6a553b0ff1de58a6b165d13c7
          Log:
          Merge pull request #27 from slide/master

          Fix JENKINS-11683, JENKINS-1144, JENKINS-11665

          Compare: https://github.com/jenkinsci/email-ext-plugin/compare/3789acf...09296a6

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: slide Path: src/main/java/hudson/plugins/emailext/EmailExtensionPlugin.java src/main/java/hudson/plugins/emailext/EmailRecepientUtils.java src/main/java/hudson/plugins/emailext/EmailType.java src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java src/main/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptor.java src/main/java/hudson/plugins/emailext/plugins/ContentBuilder.java src/main/resources/hudson/plugins/emailext/ExtendedEmailPublisher/config.jelly src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherTest.java src/test/java/hudson/plugins/emailext/plugins/ContentBuilderTest.java http://jenkins-ci.org/commit/email-ext-plugin/09296a6d5e321ea6a553b0ff1de58a6b165d13c7 Log: Merge pull request #27 from slide/master Fix JENKINS-11683 , JENKINS-1144 , JENKINS-11665 Compare: https://github.com/jenkinsci/email-ext-plugin/compare/3789acf...09296a6

          Alex Earl added a comment -

          Fixed in 09296a6

          Alex Earl added a comment - Fixed in 09296a6

            slide_o_mix Alex Earl
            brad_c brad_c
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: