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

NullPointer when using emailext templates with Groovy Trigger Script

    Details

    • Similar Issues:

      Description

      I have created a template with the following Trigger

      Script - After Build
      Trigger Script: build.result.toString().equals('SUCCESS') && build.getBuildVariables().get("publish").equals('true');

      Then I assign it to the project, that is properly configured, it has a 'publish' variable that was checked in the build, and when I built the project I got this error.

      Important Detail: With the exactly same configuration but without using templates, it work flawlessly.

      BUILD SUCCESSFUL
      Total time: 2 minutes 38 seconds
      ERROR: Build step failed with exception
      java.lang.NullPointerException
      at hudson.plugins.emailext.plugins.trigger.AbstractScriptTrigger.createEngine(AbstractScriptTrigger.java:81)
      at hudson.plugins.emailext.plugins.trigger.AbstractScriptTrigger.trigger(AbstractScriptTrigger.java:56)
      at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:274)
      at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:258)
      at org.jenkinsci.plugins.emailext_template.ExtendedEmailTemplatePublisher.perform(ExtendedEmailTemplatePublisher.java:67)
      at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
      at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723)
      at hudson.model.Build$BuildExecution.post2(Build.java:185)
      at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668)
      at hudson.model.Run.execute(Run.java:1763)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:98)
      at hudson.model.Executor.run(Executor.java:410)
      Build step 'Editable Email Notification Templates' marked build as failure
      Finished: FAILURE

        Attachments

        1. BuildLog.jpg
          BuildLog.jpg
          486 kB
        2. JobCfg1.jpg
          JobCfg1.jpg
          219 kB
        3. JobCfg2.jpg
          JobCfg2.jpg
          113 kB
        4. TemplateCfg1.jpg
          TemplateCfg1.jpg
          238 kB
        5. TemplateCfg2.jpg
          TemplateCfg2.jpg
          181 kB

          Activity

          gustavocdc Gustavo Cabral do Carmo created issue -
          gustavocdc Gustavo Cabral do Carmo made changes -
          Field Original Value New Value
          Priority Major [ 3 ] Minor [ 4 ]
          Hide
          slide_o_mix Alex Earl added a comment -

          I haven't been able to reproduce this at all, can you share your job configuration at all?

          Show
          slide_o_mix Alex Earl added a comment - I haven't been able to reproduce this at all, can you share your job configuration at all?
          gustavocdc Gustavo Cabral do Carmo made changes -
          Attachment TemplateCfg2.jpg [ 32244 ]
          Attachment TemplateCfg1.jpg [ 32245 ]
          Attachment JobCfg2.jpg [ 32246 ]
          Attachment JobCfg1.jpg [ 32247 ]
          gustavocdc Gustavo Cabral do Carmo made changes -
          Attachment BuildLog.jpg [ 32248 ]
          Hide
          gustavocdc Gustavo Cabral do Carmo added a comment - - edited

          I create a test job just to reproduce the problem, you can see the pictures in the Attachments.
          Some menus and configs are in portuguese but I'm sure you'll understand everything.

          Show
          gustavocdc Gustavo Cabral do Carmo added a comment - - edited I create a test job just to reproduce the problem, you can see the pictures in the Attachments. Some menus and configs are in portuguese but I'm sure you'll understand everything.
          Hide
          brunolavit Bruno Lavit added a comment - - edited

          Hi,

          I have the same issue with Jenkins LTS 1.625.3, Email-ext plugin 2.40.5 and Template plugin 1.5.2.

          I've tried to create a job template with the email-ext plugin and a "Script - After Build" trigger:

          build.logFile.text.readLines().any { it =~ /^Build step 'Jenkins Text Finder' changed build result to UNSTABLE/ }
          

          I got the same NPE in the job using the template:

          [TemplateProject] Starting publishers from: template - Docs
          ERROR: Build step failed with exception
          java.lang.NullPointerException
          	at hudson.plugins.emailext.plugins.trigger.AbstractScriptTrigger.createEngine(AbstractScriptTrigger.java:82)
          	at hudson.plugins.emailext.plugins.trigger.AbstractScriptTrigger.trigger(AbstractScriptTrigger.java:56)
          	at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:246)
          	at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:230)
          	at hudson.plugins.templateproject.ProxyPublisher.perform(ProxyPublisher.java:85)
          	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
          	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:785)
          	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726)
          	at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1047)
          	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671)
          	at hudson.model.Run.execute(Run.java:1766)
          	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531)
          	at hudson.model.ResourceController.execute(ResourceController.java:98)
          	at hudson.model.Executor.run(Executor.java:408)
          
          Show
          brunolavit Bruno Lavit added a comment - - edited Hi, I have the same issue with Jenkins LTS 1.625.3, Email-ext plugin 2.40.5 and Template plugin 1.5.2. I've tried to create a job template with the email-ext plugin and a "Script - After Build" trigger: build.logFile.text.readLines().any { it =~ /^Build step 'Jenkins Text Finder' changed build result to UNSTABLE/ } I got the same NPE in the job using the template: [TemplateProject] Starting publishers from: template - Docs ERROR: Build step failed with exception java.lang.NullPointerException at hudson.plugins.emailext.plugins.trigger.AbstractScriptTrigger.createEngine(AbstractScriptTrigger.java:82) at hudson.plugins.emailext.plugins.trigger.AbstractScriptTrigger.trigger(AbstractScriptTrigger.java:56) at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:246) at hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:230) at hudson.plugins.templateproject.ProxyPublisher.perform(ProxyPublisher.java:85) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:785) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726) at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1047) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671) at hudson.model.Run.execute(Run.java:1766) at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:408)
          Hide
          slide_o_mix Alex Earl added a comment -

          Ok, I am able to reproduce this issue now and know what the issue is. I'll work on a fix. It will actually be a fix in the email-ext plugin, not the emailext-template plugin.

          Show
          slide_o_mix Alex Earl added a comment - Ok, I am able to reproduce this issue now and know what the issue is. I'll work on a fix. It will actually be a fix in the email-ext plugin, not the emailext-template plugin.
          slide_o_mix Alex Earl made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          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/trigger/AbstractScriptTrigger.java
          src/test/java/hudson/plugins/emailext/AttachmentUtilsTest.java
          http://jenkins-ci.org/commit/email-ext-plugin/6a17566feeab23d8a831bfbc30990ce54eae6c81
          Log:
          Fix JENKINS-33690

          Removed explicit look for an ExtendedEmailPublisher instance to get the Jenkins url.

          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/trigger/AbstractScriptTrigger.java src/test/java/hudson/plugins/emailext/AttachmentUtilsTest.java http://jenkins-ci.org/commit/email-ext-plugin/6a17566feeab23d8a831bfbc30990ce54eae6c81 Log: Fix JENKINS-33690 Removed explicit look for an ExtendedEmailPublisher instance to get the Jenkins url.
          Hide
          brunolavit Bruno Lavit added a comment -

          Thanks Alex Earl for the quick fix !

          Show
          brunolavit Bruno Lavit added a comment - Thanks Alex Earl for the quick fix !
          Show
          slide_o_mix Alex Earl added a comment - You can use the hpi from here [1] if you want a quick version update with the fix. 1 - https://jenkins.ci.cloudbees.com/job/plugins/job/email-ext-plugin/lastBuild/org.jenkins-ci.plugins$email-ext/artifact/org.jenkins-ci.plugins/email-ext/2.42-SNAPSHOT/email-ext-2.42-SNAPSHOT.hpi
          Hide
          gustavocdc Gustavo Cabral do Carmo added a comment -

          I tested here and it worked. Thanks Alex Earl for the quick fix!

          Show
          gustavocdc Gustavo Cabral do Carmo added a comment - I tested here and it worked . Thanks Alex Earl for the quick fix!
          slide_o_mix Alex Earl made changes -
          Status In Progress [ 3 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          slide_o_mix Alex Earl made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Hide
          brunolavit Bruno Lavit added a comment -

          Yes thanks Alex for the quick fix

          Show
          brunolavit Bruno Lavit added a comment - Yes thanks Alex for the quick fix
          rtyler R. Tyler Croy made changes -
          Workflow JNJira [ 169654 ] JNJira + In-Review [ 209861 ]

            People

            • Assignee:
              slide_o_mix Alex Earl
              Reporter:
              gustavocdc Gustavo Cabral do Carmo
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: