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

    Details

    • Similar Issues:

      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

          Hide
          axelbehrens Axel Behrens added a comment -

          changed summary and description to better reflect the problem

          Show
          axelbehrens Axel Behrens added a comment - changed summary and description to better reflect the problem
          Hide
          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.

          Show
          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.
          Hide
          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.

          Show
          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.
          Hide
          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.

          Show
          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.
          Hide
          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

          Show
          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

            People

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

              Dates

              • Created:
                Updated:
                Resolved: