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

email notification can not send out whether the build is success or failed

      Email can not send out, error info as follows:
      Email was triggered for: Success
      Sending email for trigger: Success
      ERROR: Could not send email as a part of the post-build publishers.
      java.lang.NullPointerException

      or

      Email was triggered for: Success
      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(Matcher.java:598)
      at hudson.plugins.emailext.plugins.ContentBuilder$Tokenizer.appendReplacement(ContentBuilder.java:195)
      at hudson.plugins.emailext.plugins.ContentBuilder.replaceTokensWithContent(ContentBuilder.java:96)
      at hudson.plugins.emailext.plugins.ContentBuilder.transformText(ContentBuilder.java:67)
      at hudson.plugins.emailext.ExtendedEmailPublisher.setContent(ExtendedEmailPublisher.java:369)
      at hudson.plugins.emailext.ExtendedEmailPublisher.createMail(ExtendedEmailPublisher.java:274)
      at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:220)
      at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:212)
      at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:174)
      at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36)
      at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:682)
      at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:657)
      at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:635)
      at hudson.model.Build$RunnerImpl.cleanUp(Build.java:171)
      at hudson.model.Run.run(Run.java:1420)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
      at hudson.model.ResourceController.execute(ResourceController.java:88)
      at hudson.model.Executor.run(Executor.java:230)
      Finished: SUCCESS

          [JENKINS-13819] email notification can not send out whether the build is success or failed

          Alex Earl added a comment -

          Please provide the stack trace, it should not be the and as before.

          Alex Earl added a comment - Please provide the stack trace, it should not be the and as before.

          Jason Swager added a comment -

          Full stack trace from the build log:
          08:00:49 Recording test results
          08:00:49 Recording fingerprints
          08:00:49 Archiving artifacts
          08:00:49 Email was triggered for: Failure
          08:00:49 Sending email for trigger: Failure
          08:00:49 ERROR: Could not send email as a part of the post-build publishers.
          08:00:49 java.lang.NullPointerException
          08:00:49 at hudson.plugins.emailext.ExtendedEmailPublisher.createMail(ExtendedEmailPublisher.java:361)
          08:00:49 at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:259)
          08:00:49 at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:251)
          08:00:49 at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:211)
          08:00:49 at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36)
          08:00:49 at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:710)
          08:00:49 at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:685)
          08:00:49 at hudson.model.Build$RunnerImpl.cleanUp(Build.java:171)
          08:00:49 at hudson.model.Run.run(Run.java:1478)
          08:00:49 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
          08:00:49 at hudson.model.ResourceController.execute(ResourceController.java:88)
          08:00:49 at hudson.model.Executor.run(Executor.java:239)
          08:00:49
          08:00:49 Deleting project workspace... done

          Jason Swager added a comment - Full stack trace from the build log: 08:00:49 Recording test results 08:00:49 Recording fingerprints 08:00:49 Archiving artifacts 08:00:49 Email was triggered for: Failure 08:00:49 Sending email for trigger: Failure 08:00:49 ERROR: Could not send email as a part of the post-build publishers. 08:00:49 java.lang.NullPointerException 08:00:49 at hudson.plugins.emailext.ExtendedEmailPublisher.createMail(ExtendedEmailPublisher.java:361) 08:00:49 at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:259) 08:00:49 at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:251) 08:00:49 at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:211) 08:00:49 at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36) 08:00:49 at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:710) 08:00:49 at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:685) 08:00:49 at hudson.model.Build$RunnerImpl.cleanUp(Build.java:171) 08:00:49 at hudson.model.Run.run(Run.java:1478) 08:00:49 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) 08:00:49 at hudson.model.ResourceController.execute(ResourceController.java:88) 08:00:49 at hudson.model.Executor.run(Executor.java:239) 08:00:49 08:00:49 Deleting project workspace... done

          Alex Earl added a comment -

          Hmmm, that is odd...that is around this code (roughly)

          // Set the contents of the email

          msg.setSentDate(new Date());

          setSubject(type, build, msg, charset);

          Which would seem to me that the msg is not getting allocated.

          Can you provide your config.xml for your job?

          Alex Earl added a comment - Hmmm, that is odd...that is around this code (roughly) // Set the contents of the email msg.setSentDate(new Date()); setSubject(type, build, msg, charset); Which would seem to me that the msg is not getting allocated. Can you provide your config.xml for your job?

          Jason Swager added a comment -

          Here's the email-ext part of the config.xml file. Email addresses modified for corporate policy (ya know, the legal mumbo jumbo...). TEST_NOTIFY is a parameter to the build, intended to be an optional list of additional email addresses.

          <hudson.plugins.emailext.ExtendedEmailPublisher>
          <recipientList>$TEST_NOTIFY</recipientList>
          <configuredTriggers>
          <hudson.plugins.emailext.plugins.trigger.UnstableTrigger>
          <email>
          <recipientList>a@test.com,b@test.com,c@test.com</recipientList>
          <subject>SOME TEST FAILURES: ${PROJECT_DEFAULT_SUBJECT}</subject>
          <body>Not all tests passed.

          $PROJECT_DEFAULT_CONTENT</body>
          <sendToDevelopers>true</sendToDevelopers>
          <sendToRequester>true</sendToRequester>
          <includeCulprits>false</includeCulprits>
          <sendToRecipientList>true</sendToRecipientList>
          </email>
          </hudson.plugins.emailext.plugins.trigger.UnstableTrigger>
          <hudson.plugins.emailext.plugins.trigger.FailureTrigger>
          <email>
          <recipientList>a@test.com,b@test.com,c@test.com</recipientList>
          <subject>TESTS FAILED TO RUN: ${PROJECT_DEFAULT_SUBJECT}</subject>
          <body>The tests did not complete as expected.

          $PROJECT_DEFAULT_CONTENT</body>
          <sendToDevelopers>true</sendToDevelopers>
          <sendToRequester>true</sendToRequester>
          <includeCulprits>false</includeCulprits>
          <sendToRecipientList>true</sendToRecipientList>
          </email>
          </hudson.plugins.emailext.plugins.trigger.FailureTrigger>
          <hudson.plugins.emailext.plugins.trigger.SuccessTrigger>
          <email>
          <recipientList></recipientList>
          <subject>ALL TESTS PASSED: ${PROJECT_DEFAULT_SUBJECT}</subject>
          <body>All tests passed!

          $PROJECT_DEFAULT_CONTENT</body>
          <sendToDevelopers>true</sendToDevelopers>
          <sendToRequester>true</sendToRequester>
          <includeCulprits>false</includeCulprits>
          <sendToRecipientList>true</sendToRecipientList>
          </email>
          </hudson.plugins.emailext.plugins.trigger.SuccessTrigger>
          </configuredTriggers>
          <contentType>default</contentType>
          <defaultSubject>${PROJECT_NAME} ${BUILD_NUMBER}</defaultSubject>
          <defaultContent>Status: ${BUILD_STATUS}
          Job: ${BUILD_URL}
          Console: ${BUILD_URL}console</defaultContent>
          <attachmentsPattern></attachmentsPattern>
          </hudson.plugins.emailext.ExtendedEmailPublisher>

          Jason Swager added a comment - Here's the email-ext part of the config.xml file. Email addresses modified for corporate policy (ya know, the legal mumbo jumbo...). TEST_NOTIFY is a parameter to the build, intended to be an optional list of additional email addresses. <hudson.plugins.emailext.ExtendedEmailPublisher> <recipientList>$TEST_NOTIFY</recipientList> <configuredTriggers> <hudson.plugins.emailext.plugins.trigger.UnstableTrigger> <email> <recipientList>a@test.com,b@test.com,c@test.com</recipientList> <subject>SOME TEST FAILURES: ${PROJECT_DEFAULT_SUBJECT}</subject> <body>Not all tests passed. $PROJECT_DEFAULT_CONTENT</body> <sendToDevelopers>true</sendToDevelopers> <sendToRequester>true</sendToRequester> <includeCulprits>false</includeCulprits> <sendToRecipientList>true</sendToRecipientList> </email> </hudson.plugins.emailext.plugins.trigger.UnstableTrigger> <hudson.plugins.emailext.plugins.trigger.FailureTrigger> <email> <recipientList>a@test.com,b@test.com,c@test.com</recipientList> <subject>TESTS FAILED TO RUN: ${PROJECT_DEFAULT_SUBJECT}</subject> <body>The tests did not complete as expected. $PROJECT_DEFAULT_CONTENT</body> <sendToDevelopers>true</sendToDevelopers> <sendToRequester>true</sendToRequester> <includeCulprits>false</includeCulprits> <sendToRecipientList>true</sendToRecipientList> </email> </hudson.plugins.emailext.plugins.trigger.FailureTrigger> <hudson.plugins.emailext.plugins.trigger.SuccessTrigger> <email> <recipientList></recipientList> <subject>ALL TESTS PASSED: ${PROJECT_DEFAULT_SUBJECT}</subject> <body>All tests passed! $PROJECT_DEFAULT_CONTENT</body> <sendToDevelopers>true</sendToDevelopers> <sendToRequester>true</sendToRequester> <includeCulprits>false</includeCulprits> <sendToRecipientList>true</sendToRecipientList> </email> </hudson.plugins.emailext.plugins.trigger.SuccessTrigger> </configuredTriggers> <contentType>default</contentType> <defaultSubject>${PROJECT_NAME} ${BUILD_NUMBER}</defaultSubject> <defaultContent>Status: ${BUILD_STATUS} Job: ${BUILD_URL} Console: ${BUILD_URL}console</defaultContent> <attachmentsPattern></attachmentsPattern> </hudson.plugins.emailext.ExtendedEmailPublisher>

          Alex Earl added a comment -

          Does it only fail for specific job statuses, or for all of them?

          Alex Earl added a comment - Does it only fail for specific job statuses, or for all of them?

          Jason Swager added a comment -

          Just failures - or at least that I know of.

          Jason Swager added a comment - Just failures - or at least that I know of.

          In my project, the new job failed, but for the old jobs , it can works well.

          pangpang wanzi added a comment - In my project, the new job failed, but for the old jobs , it can works well.

          another strange case: if the project triggered by upstream job, the email notification failed, but if triggered by me(manuely), it can send email successfully. Is there any ralation with who triggered the problem?

          pangpang wanzi added a comment - another strange case: if the project triggered by upstream job, the email notification failed, but if triggered by me(manuely), it can send email successfully. Is there any ralation with who triggered the problem?

          hi, it there any difference between triggered by jenkins to triggered manually? Now, the email can send out every time when I triggered manually, but failed to sent when triggered by upstream job.

          pangpang wanzi added a comment - hi, it there any difference between triggered by jenkins to triggered manually? Now, the email can send out every time when I triggered manually, but failed to sent when triggered by upstream job.

          Alex Earl added a comment -

          You are using an older version of the plugin, can you update to 2.21 and see if you see the issue still?

          Alex Earl added a comment - You are using an older version of the plugin, can you update to 2.21 and see if you see the issue still?

            slide_o_mix Alex Earl
            pangpangwanzi pangpang wanzi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: