Robot Summary Results table within Jenkins email-ext template

5,703 views
Skip to first unread message

Shawn Speer

unread,
Jan 20, 2014, 4:28:53 PM1/20/14
to robotframe...@googlegroups.com

Hello,

  I am trying to find a way to replicate the 'Robot Summary Results' table (below), that is displayed within each job output page in Jenkins, in the e-mail notification for the job.  I can't seem to find an example or whether the variables are available to provide this information within an email template/script.   I did find a great blog here that describes how to get each test case and its result within the e-mail. I can add a counter to this to get the stats, although I'm not sure if I can separate the critical test counts (They are all critical tests in the sample below, but this will change), but I thought that these would already be available to use within the template or script.

Thanks,
Shawn

Janne Piironen

unread,
Jan 21, 2014, 4:50:22 AM1/21/14
to robotframe...@googlegroups.com
Hi, 

There are some variables available for easy consumption, if you have also the Token Macro plugin [1] installed. The available variables are  overviewed on the Robot Framework plugin wiki page [2] under the topic "Using token macros in e-mail report".

However, since the test case count variables expand to format "xxx/total" you cannot reproduce the summary table per se with them. If you need to accurately recreate the table you could proceed like in the post you mentioned. If you first get hold of the build action object in a variable named "action" like in the post then you can retrieve critical / non-critical test counts with groovy with the following:

//All tests
action.result.overallPassed
action.result.overallFailed
action.result.overallTotal

//Critical tests
action.result.criticalPassed
action.result.criticalFailed
action.result.criticalTotal



BR,
Janne

Shawn Speer

unread,
Jan 21, 2014, 10:54:32 AM1/21/14
to robotframe...@googlegroups.com
Thanks Janne!  The variables that you list are exactly what I was looking for.   I was able to loosely recreate the table in my e-mail notification.    For anyone else interested, I've attached the groovy script that I am using for this.

Shawn
robot_summary.groovy

Janne Piironen

unread,
Jan 24, 2014, 6:31:35 AM1/24/14
to robotframe...@googlegroups.com
I also added an issue [1] for splitting the test count tokens included in the plugin for easier formatting. It will be done for the next release, which is due soon.

-Janne

zephirus

unread,
Sep 23, 2014, 10:26:22 AM9/23/14
to robotframe...@googlegroups.com
Hi all,

Can someone help me get the test results by email? I downloaded the groovy script but I don't know how to use it or where to put it.

I always get an email with this error:

Error in script or template: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script1.groovy: 1: unexpected token: < @ line 1, column 1. <% ^ 1 error 


I only have the robot framework and ext-email plugins installed. Do I need to install anything more?


Thanks in advance!

Kevin O.

unread,
Sep 23, 2014, 10:49:36 AM9/23/14
to robotframe...@googlegroups.com
Since its a template, you  won't be able to compile it with Groovy directly.
Place it in the <JENKINS_HOME>/email-templates folder on Master
Configure the email-ext plugin like this:
Content Type = HTML
Default Content = ${SCRIPT, script="email-ext.groovy", template="with_results.groovy", init="false"}


Kevin

zephirus

unread,
Sep 23, 2014, 11:00:22 AM9/23/14
to robotframe...@googlegroups.com
Thanks Kevin,

Now I get a different error: [Error replacing 'SCRIPT' - Undefined parameter init in token SCRIPT]

I still don't have any other plugins that are in some posts before, so... what am I doing wrong here?

Kevin O.

unread,
Sep 23, 2014, 11:14:32 AM9/23/14
to robotframe...@googlegroups.com
I do not know, but the init parameter is not required. Try removing it.

zephirus

unread,
Sep 23, 2014, 11:29:19 AM9/23/14
to robotframe...@googlegroups.com
Hi again Kevin,

Sorry for all these questions... I removed the init parameter and now (guess what), I get a different error:

Error in script or template: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script1.groovy: 1: unexpected token: < @ line 1, column 1. 


Maybe I don't have the correct files??? (email-ext.groovy and with_results.groovy)

Where can I get these?

Kevin O.

unread,
Sep 23, 2014, 1:39:58 PM9/23/14
to robotframe...@googlegroups.com
That init thing still makes me think you might be doing something different. The ${SCRIPT ... part goes into the Default Content box in the "Editable Email Notification" post-build step that comes after the "Publish Robot Framework test results" step.
To simplify things, you can just change the Default Content to ${SCRIPT, template="with_results.groovy"}
email-ext.groovy is the default option for script anyways and init probably doesn't matter
with_results.groovy is a template, saved in <JENKINS_HOME>/email-templates folder on Master, and is a script similar to the following:

Saurabh Thakkar

unread,
Apr 11, 2017, 4:49:04 AM4/11/17
to robotframework-users, zephi...@gmail.com
I am getting the exact same error. Did you find a way out of it?
It would really help if you can tell me how did you solve this issue.

אדיר אטיאס

unread,
Feb 1, 2018, 11:57:23 AM2/1/18
to robotframework-users
Hi All,

is it possible to use this Robot Email template as part of scripted pipeline ?
emailext (
subject: "SUCCESS: '${env.JOB_NAME}'",
body: '${SCRIPT, template="general.groovy"}'
to: recipientsList
)

it looks like it doesn't recognize the properties and raise exceptions:

Exception raised during template rendering: No such property: style_tr for class: SimpleTemplateScript4 groovy.lang.MissingPropertyException: No such property: style_tr for class: SimpleTemplateScript4 at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53) at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:52) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:

Sahil Guleria

unread,
Aug 6, 2018, 4:15:53 AM8/6/18
to robotframework-users
You can use this 
${SCRIPT, template="robot_summary.groovy"}

This worked for me and FYI create the email-templates folder  and the groovy file as jenkins user.

Swayam Prakash

unread,
Aug 12, 2018, 3:42:10 AM8/12/18
to robotframework-users
Does Any body got a solution on how to use   Robot Email template as part of scripted pipeline ?

Shiva Prasad Adirala

unread,
Aug 12, 2018, 1:59:39 PM8/12/18
to robotframework-users
Can you take a look into following link. This seems similar to your requirement https://github.com/vladwa/robot-email-template

mantri sri

unread,
Aug 12, 2018, 7:40:29 PM8/12/18
to robotframework-users
Hi Kevin,

I was trying configured as you mentioned below.

I have this below path in Jenkins master for email-ext templates 
/opt/drutt/ca/jenkins/home/plugins/emailext-template   and copied the with_results.groovy file in this location.

Attached the document for this issue, can you please help to resolve this issue that could be really helpful.
JenkinsIssue.docx

Swayam Prakash

unread,
Aug 12, 2018, 11:35:48 PM8/12/18
to robotframework-users
I am using this template but after receiving the mail in the mail body I can see 

Exception raised during template rendering: Cannot get property 'simpleName' on null

In the groovy template  if( action.class.simpleName.equals("RobotBuildAction") ) { //

Any idea how to fix this?

zhang yiyang

unread,
Oct 11, 2018, 9:34:11 PM10/11/18
to robotframework-users
Hello Swayam,

I am using this template too, did you fix it?

wywin...@gmail.com

unread,
Oct 14, 2018, 7:06:37 AM10/14/18
to robotframework-users
I am also using this email template (robot_result.groovy) in jenkins pipeline script, and it will cause an exception like :

Cannot get property 'simpleName' on null

Is Jenkinsfile doesn't support robot email template?

Can anyone help us?

在 2018年10月12日星期五 UTC+8上午9:34:11,zhang yiyang写道:

xuyong...@gmail.com

unread,
Oct 24, 2018, 7:19:23 AM10/24/18
to robotframework-users
we also got exactly same error when using this script, any suggestions?

Exception raised during template rendering: Cannot get property 'simpleName' on null object java.lang.NullPointerException: Cannot get property 'simpleName' on null object at org.codehaus.groovy.runtime

if( action.class.simpleName.equals("RobotBuildAction"))
{

Daniel Rose

unread,
Dec 20, 2018, 1:21:28 AM12/20/18
to robotframework-users

replace

    if( action.class.simpleName.equals("RobotBuildAction") ) { //

with

    if( action instanceof hudson.plugins.robot.RobotBuildAction ) { //

and it will at least compile and send

yiyang zhang

unread,
Dec 25, 2018, 2:18:50 AM12/25/18
to ultima...@gmail.com, robotframework-users
Thank you so much, Daniel!

Daniel Rose <ultima...@gmail.com>于2018年12月20日 周四14:21写道:
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.
--
Sent from my mobile.
Reply all
Reply to author
Forward
0 new messages