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

Use of jelly template leads to NPE in email-ext 2.35.1 in combination with template project plugin

    XMLWordPrintable

Details

    Description

      when sending an email with default content

      ${JELLY_SCRIPT}
      

      the token is not replaced and the jenkins log shows the following stack trace:

      Okt 18, 2013 8:21:02 AM SEVERE hudson.plugins.emailext.plugins.ContentBuilder transformText
      null
      java.lang.NullPointerException
      	at hudson.plugins.emailext.plugins.content.JellyScriptContent.createContext(JellyScriptContent.java:132)
      	at hudson.plugins.emailext.plugins.content.JellyScriptContent.renderContent(JellyScriptContent.java:107)
      	at hudson.plugins.emailext.plugins.content.JellyScriptContent.evaluate(JellyScriptContent.java:64)
      	at org.jenkinsci.plugins.tokenmacro.DataBoundTokenMacro.evaluate(DataBoundTokenMacro.java:177)
      	at org.jenkinsci.plugins.tokenmacro.TokenMacro.expand(TokenMacro.java:182)
      	at org.jenkinsci.plugins.tokenmacro.TokenMacro.expandAll(TokenMacro.java:233)
      	at hudson.plugins.emailext.plugins.ContentBuilder.transformText(ContentBuilder.java:63)
      	at hudson.plugins.emailext.ExtendedEmailPublisher.getContent(ExtendedEmailPublisher.java:698)
      	at hudson.plugins.emailext.ExtendedEmailPublisher.createMail(ExtendedEmailPublisher.java:456)
      	at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:280)
      	at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:272)
      	at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:232)
      	at hudson.plugins.templateproject.ProxyPublisher.perform(ProxyPublisher.java:69)
      	at hudson.tasks.BuildStepMonitor$2.perform(BuildStepMonitor.java:32)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:781)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:753)
      	at hudson.model.Build$BuildExecution.post2(Build.java:183)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:706)
      	at hudson.model.Run.execute(Run.java:1690)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
      	at hudson.model.ResourceController.execute(ResourceController.java:88)
      	at hudson.model.Executor.run(Executor.java:246)
      

      This only happens if the email-ext publisher is used in combination with the template project plugin.

      Attachments

        Activity

          axelbehrens Axel Behrens created issue -
          slide_o_mix Alex Earl added a comment -

          Looks like the publisher is not being returned correctly from the project. What type of job are you running?

          slide_o_mix Alex Earl added a comment - Looks like the publisher is not being returned correctly from the project. What type of job are you running?
          slide_o_mix Alex Earl added a comment -

          I just tried this on a local install and it worked fine for me, please give more information.

          slide_o_mix Alex Earl added a comment - I just tried this on a local install and it worked fine for me, please give more information.
          axelbehrens Axel Behrens added a comment -

          This can be reproduced with a free-style job containing the email-ext publisher and another free-style job using the publisher 'Use publishers from another project' from the Template Project Plugin pointing to the first job.

          axelbehrens Axel Behrens added a comment - This can be reproduced with a free-style job containing the email-ext publisher and another free-style job using the publisher 'Use publishers from another project' from the Template Project Plugin pointing to the first job.
          bendlerd Dan Bendler added a comment -

          I receive a NPE as well, using the ${SCRIPT, template="myTemplate.template"} token.
          The stack trace is similar but not identical:
          FATAL: null
          java.lang.NullPointerException
          at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:243)
          at hudson.plugins.emailext.ExtendedEmailPublisher.prebuild(ExtendedEmailPublisher.java:222)
          at hudson.model.AbstractBuild$AbstractBuildExecution.preBuild(AbstractBuild.java:815)
          at hudson.model.AbstractBuild$AbstractBuildExecution.preBuild(AbstractBuild.java:810)
          at hudson.model.Build$BuildExecution.doRun(Build.java:142)
          at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:562)
          at hudson.model.Run.execute(Run.java:1665)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
          at hudson.model.ResourceController.execute(ResourceController.java:88)
          at hudson.model.Executor.run(Executor.java:230)

          bendlerd Dan Bendler added a comment - I receive a NPE as well, using the ${SCRIPT, template="myTemplate.template"} token. The stack trace is similar but not identical: FATAL: null java.lang.NullPointerException at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:243) at hudson.plugins.emailext.ExtendedEmailPublisher.prebuild(ExtendedEmailPublisher.java:222) at hudson.model.AbstractBuild$AbstractBuildExecution.preBuild(AbstractBuild.java:815) at hudson.model.AbstractBuild$AbstractBuildExecution.preBuild(AbstractBuild.java:810) at hudson.model.Build$BuildExecution.doRun(Build.java:142) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:562) at hudson.model.Run.execute(Run.java:1665) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:230)
          slide_o_mix Alex Earl added a comment - - edited

          @Dan are you also using the template project plugin? Also, are you using 2.35.1?

          slide_o_mix Alex Earl added a comment - - edited @Dan are you also using the template project plugin? Also, are you using 2.35.1?
          slide_o_mix Alex Earl made changes -
          Field Original Value New Value
          Link This issue is duplicated by JENKINS-20183 [ JENKINS-20183 ]
          bendlerd Dan Bendler added a comment -

          Using 2.35.1, but I'm not using the template project plugin.
          I have the default content for the email-ext defined in the Jenkins global configurations, and in it I'm using a script content I created (which was working perfectly the past 3 months).

          bendlerd Dan Bendler added a comment - Using 2.35.1, but I'm not using the template project plugin. I have the default content for the email-ext defined in the Jenkins global configurations, and in it I'm using a script content I created (which was working perfectly the past 3 months).
          slide_o_mix Alex Earl added a comment -

          @Dan, I think your issue is an issue someone flagged and made a pull request for. I think it is different from the error that the OP submitted.

          slide_o_mix Alex Earl added a comment - @Dan, I think your issue is an issue someone flagged and made a pull request for. I think it is different from the error that the OP submitted.
          slide_o_mix Alex Earl made changes -
          Link This issue is duplicated by JENKINS-20183 [ JENKINS-20183 ]

          I'm seeing something similar to @Dan:

          FATAL: null
          java.lang.NullPointerException
          at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:242)
          at hudson.plugins.emailext.ExtendedEmailPublisher.prebuild(ExtendedEmailPublisher.java:222)
          at hudson.model.AbstractBuild$AbstractBuildExecution.preBuild(AbstractBuild.java:814)
          at hudson.model.AbstractBuild$AbstractBuildExecution.preBuild(AbstractBuild.java:809)
          at hudson.model.Build$BuildExecution.doRun(Build.java:142)
          at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:565)
          at hudson.model.Run.execute(Run.java:1592)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
          at hudson.model.ResourceController.execute(ResourceController.java:88)
          at hudson.model.Executor.run(Executor.java:237)

          1.509.4 LTS, Jenkins Email Extension Plugin 2.35.1, Template Project plugin 1.4

          lgadalla Larry Gadallah added a comment - I'm seeing something similar to @Dan: FATAL: null java.lang.NullPointerException at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:242) at hudson.plugins.emailext.ExtendedEmailPublisher.prebuild(ExtendedEmailPublisher.java:222) at hudson.model.AbstractBuild$AbstractBuildExecution.preBuild(AbstractBuild.java:814) at hudson.model.AbstractBuild$AbstractBuildExecution.preBuild(AbstractBuild.java:809) at hudson.model.Build$BuildExecution.doRun(Build.java:142) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:565) at hudson.model.Run.execute(Run.java:1592) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:237) 1.509.4 LTS, Jenkins Email Extension Plugin 2.35.1, Template Project plugin 1.4
          slide_o_mix Alex Earl added a comment -

          @Larry Yes, I already addressed that one. Please see https://issues.jenkins-ci.org/browse/JENKINS-20183

          slide_o_mix Alex Earl added a comment - @Larry Yes, I already addressed that one. Please see https://issues.jenkins-ci.org/browse/JENKINS-20183
          axelbehrens Axel Behrens added a comment -

          changed summary and description to better reflect the problem

          axelbehrens Axel Behrens added a comment - changed summary and description to better reflect the problem
          axelbehrens Axel Behrens made changes -
          Description when sending an email with default content
          {noformat}
          ${JELLY_SCRIPT}
          {noformat}
          the token is not replaced and the jenkins log show the following stack trace:
          {noformat}
          Okt 18, 2013 8:21:02 AM SEVERE hudson.plugins.emailext.plugins.ContentBuilder transformText
          null
          java.lang.NullPointerException
          at hudson.plugins.emailext.plugins.content.JellyScriptContent.createContext(JellyScriptContent.java:132)
          at hudson.plugins.emailext.plugins.content.JellyScriptContent.renderContent(JellyScriptContent.java:107)
          at hudson.plugins.emailext.plugins.content.JellyScriptContent.evaluate(JellyScriptContent.java:64)
          at org.jenkinsci.plugins.tokenmacro.DataBoundTokenMacro.evaluate(DataBoundTokenMacro.java:177)
          at org.jenkinsci.plugins.tokenmacro.TokenMacro.expand(TokenMacro.java:182)
          at org.jenkinsci.plugins.tokenmacro.TokenMacro.expandAll(TokenMacro.java:233)
          at hudson.plugins.emailext.plugins.ContentBuilder.transformText(ContentBuilder.java:63)
          at hudson.plugins.emailext.ExtendedEmailPublisher.getContent(ExtendedEmailPublisher.java:698)
          at hudson.plugins.emailext.ExtendedEmailPublisher.createMail(ExtendedEmailPublisher.java:456)
          at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:280)
          at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:272)
          at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:232)
          at hudson.plugins.templateproject.ProxyPublisher.perform(ProxyPublisher.java:69)
          at hudson.tasks.BuildStepMonitor$2.perform(BuildStepMonitor.java:32)
          at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:781)
          at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:753)
          at hudson.model.Build$BuildExecution.post2(Build.java:183)
          at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:706)
          at hudson.model.Run.execute(Run.java:1690)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
          at hudson.model.ResourceController.execute(ResourceController.java:88)
          at hudson.model.Executor.run(Executor.java:246)
          {noformat}
          when sending an email with default content
          {noformat}
          ${JELLY_SCRIPT}
          {noformat}
          the token is not replaced and the jenkins log shows the following stack trace:
          {noformat}
          Okt 18, 2013 8:21:02 AM SEVERE hudson.plugins.emailext.plugins.ContentBuilder transformText
          null
          java.lang.NullPointerException
          at hudson.plugins.emailext.plugins.content.JellyScriptContent.createContext(JellyScriptContent.java:132)
          at hudson.plugins.emailext.plugins.content.JellyScriptContent.renderContent(JellyScriptContent.java:107)
          at hudson.plugins.emailext.plugins.content.JellyScriptContent.evaluate(JellyScriptContent.java:64)
          at org.jenkinsci.plugins.tokenmacro.DataBoundTokenMacro.evaluate(DataBoundTokenMacro.java:177)
          at org.jenkinsci.plugins.tokenmacro.TokenMacro.expand(TokenMacro.java:182)
          at org.jenkinsci.plugins.tokenmacro.TokenMacro.expandAll(TokenMacro.java:233)
          at hudson.plugins.emailext.plugins.ContentBuilder.transformText(ContentBuilder.java:63)
          at hudson.plugins.emailext.ExtendedEmailPublisher.getContent(ExtendedEmailPublisher.java:698)
          at hudson.plugins.emailext.ExtendedEmailPublisher.createMail(ExtendedEmailPublisher.java:456)
          at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:280)
          at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:272)
          at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:232)
          at hudson.plugins.templateproject.ProxyPublisher.perform(ProxyPublisher.java:69)
          at hudson.tasks.BuildStepMonitor$2.perform(BuildStepMonitor.java:32)
          at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:781)
          at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:753)
          at hudson.model.Build$BuildExecution.post2(Build.java:183)
          at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:706)
          at hudson.model.Run.execute(Run.java:1690)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
          at hudson.model.ResourceController.execute(ResourceController.java:88)
          at hudson.model.Executor.run(Executor.java:246)
          {noformat}
          This only happens if the email-ext publisher is used in combination with the template project plugin.
          Summary Use of jelly template leads to NPE in email-ext 2.35.1 Use of jelly template leads to NPE in email-ext 2.35.1 in combination with template project plugin
          slide_o_mix Alex Earl added a comment -

          @Axel, I'll install the template project plugin and see if I can get to the bottom of this.

          slide_o_mix Alex Earl added a comment - @Axel, I'll install the template project plugin and see if I can get to the bottom of this.
          slide_o_mix Alex Earl added a comment -

          Ok, it looks like what is happening is that the template project plugin provides a project project for AbstractBuild.getProject(), the proxy project does not have the publishers list the same as a real project, so ExtendedEmailPublisher doesn't show up. So, what I plan to do in the places where I was calling build.getProject() to get access to the descriptor, I'm just using Jenkins.getInstance().getDescriptorByType(ExtendedEmailPublisherDescriptor.class). This goes around the issue with the way template project does things.

          slide_o_mix Alex Earl added a comment - Ok, it looks like what is happening is that the template project plugin provides a project project for AbstractBuild.getProject(), the proxy project does not have the publishers list the same as a real project, so ExtendedEmailPublisher doesn't show up. So, what I plan to do in the places where I was calling build.getProject() to get access to the descriptor, I'm just using Jenkins.getInstance().getDescriptorByType(ExtendedEmailPublisherDescriptor.class). This goes around the issue with the way template project does things.

          Code changed in jenkins
          User: Alex Earl
          Path:
          src/main/java/hudson/plugins/emailext/plugins/content/JellyScriptContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/ScriptContent.java
          http://jenkins-ci.org/commit/email-ext-plugin/6fc8eae1bc2b4f379e35868a0f7d79a485373fb1
          Log:
          Fix JENKINS-20117

          Switched to using
          Jenkins.getInstance().getDescriptorByType(ExtendedEmailPublisherDescriptor)
          instead of
          build.getProject().getPublishersList().get(ExtendedEmailPublisher.class)
          to get access to the descriptor.

          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Alex Earl Path: src/main/java/hudson/plugins/emailext/plugins/content/JellyScriptContent.java src/main/java/hudson/plugins/emailext/plugins/content/ScriptContent.java http://jenkins-ci.org/commit/email-ext-plugin/6fc8eae1bc2b4f379e35868a0f7d79a485373fb1 Log: Fix JENKINS-20117 Switched to using Jenkins.getInstance().getDescriptorByType(ExtendedEmailPublisherDescriptor) instead of build.getProject().getPublishersList().get(ExtendedEmailPublisher.class) to get access to the descriptor.
          slide_o_mix Alex Earl made changes -
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Resolved [ 5 ]
          axelbehrens Axel Behrens added a comment -

          @Alex: I can confirm that it's working now either w/ or w/o the template project plugin involved using the latest SNAPSHOT from https://jenkins.ci.cloudbees.com/.

          Cheers,
          Axel

          axelbehrens Axel Behrens added a comment - @Alex: I can confirm that it's working now either w/ or w/o the template project plugin involved using the latest SNAPSHOT from https://jenkins.ci.cloudbees.com/ . Cheers, Axel
          axelbehrens Axel Behrens made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          rtyler R. Tyler Croy made changes -
          Workflow JNJira [ 151639 ] JNJira + In-Review [ 207045 ]

          People

            slide_o_mix Alex Earl
            axelbehrens Axel Behrens
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: