cucumber-reports does not contain CucumberTestResultAction so the action will never be added by it which is the main issue you have.
CucumberTestResultAction is provided by the cucumber-testresult plugin <https://plugins.jenkins.io/cucumber-testresult-plugin/> cucmber-reports as far as I am aware does (at least did not) not provide a model you can inteorogate or otherwise integrate with Jenkins and is a mostly dumb publisher around converted HTML. /James On Monday, 14 February 2022 at 06:31:17 UTC Oxygen wrote: > 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/4933956d-03d2-405d-93ad-7a8ad33e37adn%40googlegroups.com.
