On Thursday, November 24, 2016 at 11:45:16 AM UTC+5:30, Baptiste Mathus
wrote:
>
> So what does not work? What is the error?
>
Code : I want to print TestName after parsing the JUNIT xml. I want to
parse the jUNIT and fill the table,
<table cellspacing="0" cellpadding="2" border="1">
<thead>
<tr bgcolor="#F3F3F3">
<td class="header">Test Name
<% def junitResultList = it.JUnitTestResult
try {
def cucumberTestResultAction =
it.getAction("org.jenkinsci.plugins.cucumber.jsontestsupport.CucumberTestResultAction")
junitResultList.add(cucumberTestResultAction.getResult())
} catch(e) {
//cucumberTestResultAction not exist in this build
}
if (junitResultList.size() > 0) { %>
<TABLE width="100%">
<TR><TD class="bg1"
colspan="2"><B>${junitResultList.first().displayName}</B></TD></TR>
<% junitResultList.each{
junitResult -> %>
<% junitResult.getChildren().each { packageResult -> %>
<TR><TD class="bg2" colspan="2"> ${packageResult.getName()} }
</TD></TR>
<% } %>
</td>
<td class="header">Test Status</td>
<td class="header">Pass</td>
<td class="header">Fail</td>
<td class="header">Total</td>
</tr>
</thead>
</table>
It fails with Parsing Error. The error message is also not clear.
Exception raised during template rendering: Failed to parse template script
(your template may contain an error or be trying to use expressions not
currently supported): startup failed: SimpleTemplateScript61.groovy: 424:
expecting '}', found '' @ line 424, column 40. /* Generated by
SimpleTemplateEngine */ ^ 1 error groovy.lang.GroovyRuntimeException:
Failed to parse template script (your template may contain an error or be
trying to use expressions not currently supported): startup failed:
SimpleTemplateScript61.groovy: 424: expecting '}', found '' @ line 424,
column 40. /* Generated by SimpleTemplateEngine */ ^ 1 error at
groovy.text.SimpleTemplateEngine.createTemplate(SimpleTemplateEngine.java:125)
at groovy.text.TemplateEngine.createTemplate(TemplateEngine.java:38) at
hudson.plugins.emailext.plugins.content.ScriptContent.renderTemplate(ScriptContent.java:128)
at
hudson.plugins.emailext.plugins.content.ScriptContent.evaluate(ScriptContent.java:69)
at
hudson.plugins.emailext.EmailExtTemplateAction.renderTemplate(EmailExtTemplateAction.java:132)
at sun.reflect.GeneratedMethodAccessor1346.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
java.lang.reflect.Method.invoke(Unknown Source) at
org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:298) at
org.kohsuke.stapler.Function.bindAndInvoke(Function.java:161) at
org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:96)
at
Is there a document I can refer for syntax to while writing groovy template
script?
Regards
Pradeep
> Le 24 nov. 2016 6:21 AM, "Bubunia Patra" <[email protected]
> <javascript:>> a écrit :
>
> Hi all,
>
> I am new to groovy and the syntax is very confusing and error prone and
> written a template to work with Email-Extn plugin. I want to add the test
> result in the tabular format as below. Can anyone help me in this regard?
>
> Regards
> Pradeep
>
> For exp if 1 test executed then i want a table in the email-body as
> follows:
>
> TestName | Test Status | Pass | Fail | Total
>
> abc | Pass | 1 | 0 | 1
>
> <table cellspacing="0" cellpadding="2" border="1">
> <thead>
> <tr bgcolor="#F3F3F3">
> <td class="header">Test Name</td>
> <td class="header">Test Status</td>
> <td class="header">Pass</td>
> <td class="header">Fail</td>
> <td class="header">Total</td>
> </tr>
> </thead>
> </table>
>
> <% def junitResultList = it.JUnitTestResult
> try {
> def cucumberTestResultAction =
> it.getAction("org.jenkinsci.plugins.cucumber.jsontestsupport.CucumberTestResultAction")
> junitResultList.add(cucumberTestResultAction.getResult())
> } catch(e) {
> //cucumberTestResultAction not exist in this build
> }
> if (junitResultList.size() > 0) { %>
> <TABLE width="100%">
> <TR><TD class="bg1"
> colspan="2"><B>${junitResultList.first().displayName}</B></TD></TR>
> <% junitResultList.each{
> junitResult -> %>
> <% junitResult.getChildren().each { packageResult -> %>
> <TR><TD class="bg2" colspan="2"> ${packageResult.getName()}
> ${packageResult.getFailCount()},${packageResult.getPassCount()},${packageResult.getSkipCount()},${packageResult.getPassCount()+packageResult.getFailCount()+packageResult.getSkipCount()}</TD></TR>
> <% packageResult.getFailedTests().each{ failed_test -> %>
> <TR bgcolor="white"><TD class="test_failed"
> colspan="2"><B><li>Failed: ${failed_test.getFullName()} </li></B></TD></TR>
> <% }
> }
> } %>
> </TABLE>
> <BR/>
> <%
> } %>
>
> --
> 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] <javascript:>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/cc06fcf9-7be4-40ad-8437-a5da816206b7%40googlegroups.com
>
> <https://groups.google.com/d/msgid/jenkinsci-users/cc06fcf9-7be4-40ad-8437-a5da816206b7%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>
--
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/a6cf0e5a-bdc2-4221-b3c9-e64ca293e2c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.