I need to write a groovy email template to send HTML email in a Jenkins job, I copied the following example and made some changes, https://github.com/jenkinsci/email-ext-plugin/blob/master/src/main/resources/hudson/plugins/emailext/templates/groovy-html.template
I found that the following call returns null even if the job has the the plugin "Cucumber reports <https://plugins.jenkins.io/cucumber-reports/>" configured in post-build actions it.getAction("org.jenkinsci.plugins.cucumber.jsontestsupport.CucumberTestResultAction") it threw the following exception: Exception raised during template rendering: Cannot invoke method getResult() on null object java.lang.NullPointerException: Cannot invoke method getResult() on null object at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:91) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:35) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117) at SimpleTemplateScript36.run(SimpleTemplateScript36.groovy:5) at groovy.text.SimpleTemplateEngine$SimpleTemplate$1.writeTo(SimpleTemplateEngine.java:168) at groovy.text.SimpleTemplateEngine$SimpleTemplate$1.toString(SimpleTemplateEngine.java:180) How can I get the actual Cucumber test results in groovy template? by the way what is the predefined variable it in the template, what's the class type of it, I am curious about it. the groovy template is as follows: <BODY> <% def featureResults=[] def cucumberTestResultAction = it.getAction("org.jenkinsci.plugins.cucumber.jsontestsupport.CucumberTestResultAction") featureResults=cucumberTestResultAction.getResult() def fail_test=0 def passed_test=0 def skip_test=0 def total_tests=0 featureResults.each { fResult -> fail_test=fail_test+fResult.getFailCount() passed_test=passed_test+fResult.getPassCount() skip_test=skip_test+fResult.getSkipCount() } total_tests=fail_test+passed_test+skip_test %> </BODY> the job is configured with the plugin Cucumber reports <https://plugins.jenkins.io/cucumber-reports/> for generating Cucumber test report, but it doesn't use *cucumber-plugin <https://github.com/melezhik/cucumber-plugin>, *it runs tests with gradle command line. Thanks -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/93bc0018-45b7-42a0-a978-9122a75cc633n%40googlegroups.com.
