Template to send a better report by email

63 views
Skip to first unread message

Antonio Hernandez

unread,
May 19, 2016, 6:42:35 AM5/19/16
to Jenkins Users
Hi everyone,

I'm working now in a better way to send a report by email because the report i have now is a pretty useless because the only thing it sending is a attatched report like this:

Ejecutando en el nodo principalen el espacio de trabajo /home/locken/JENKINS_HOME/jobs/Nightly_LSA_Evolution_TESTS/workspace
No emails were triggered.
executing script 'Run_All_Nightly_Tests'
[workspace] $ /bin/sh /tmp/build_step_template6325968638781665777.sh


-------------------------------
Nightly.TC01 --> started!
---------> Step 01 OK!
---------> Step 02 OK!
---------> Steps 03 & 04 OK!
---------> Step 05 OK!
---------> Step 06 OK!
---------> Step 07 OK!
---------> Step 08 OK!
---------> Step 09 OK!
Nightly.TC01 --> OK!
-------------------------------


-------------------------------
Nightly.TC02 --> started!
---------> Step 01 OK!
---------> Step 02 OK!
---------> Steps 03 & 04 & 05 OK!
---------> Step 06 OK!
---------> Step 07 OK!
---------> Step 08 OK!
---------> Step 09 OK!
---------> Step 10 OK!
---------> Steps 11 & 12 OK!
---------> Step 13 OK!
---------> Step 14 OK!
Nightly.TC02 --> OK!
.
.
.
.
I'm using Editable Email Notificacion plugin but i don't know to use it in a better way to create a mail with written the body with build.log and a warning if the build was wrong or a check if it was fine


I'm using this script (thanks to zerozerounouno one more time!!!!!!!!

// Fail for Java exceptions
if(manager.logContains(".*Exception in thread.*")) {
      manager.addErrorBadge("Java exception")
      manager.createSummary("warning.gif").appendText("<h3>Java exception detected.</h3>", false, false, false, "red")
      manager.buildFailure()
}

and it's working fine in order to know at the end if the job was OK or KO but i want to add something like that in the email´s body


Thanks in advance 

Antonio Hernandez

unread,
May 20, 2016, 2:44:02 AM5/20/16
to Jenkins Users
Hi again,
I worked around it and i have a template attached but no variable is being resolved and the email is something like this:


--------------------------------

BUILD ${build.result}

Build URL

${rooturl}${build.url}

Project:

${project.name}

Date of build:

${it.timestampString}

Build duration:

${build.durationString}

Build cause:

<% for (hudson.model.Cause cause : build.causes) { %>

${cause.shortDescription}

<% } %>

Build description:

${build.description}

Built on:

${built_on}

Total Builds:

${total_builds}

FAILURES:

${total_failed} out of ${total_builds} builds FAILED!

<% if (healthReports != null) { %>

Health Report

W

Description

Score

${healthReport.description}

${healthReport.score}



<% } %>

<% if (build.changeSet != null) { boolean hadChanges = false hudson.scm.ChangeLogSet cs = build.getChangeSet() %>

 

<% for (hudson.scm.ChangeLogSet.Entry entry : cs) { hadChanges = true %>

${entry.msgAnnotated}

by ${entry.author}

<% for (hudson.scm.ChangeLogSet.AffectedFile p : entry.affectedFiles) { %>

${p.editType.name}

${p.path}

<% } if (hadChanges == false) { %>No Changes

<% } } %>Architecture Summary

<% for (String __val : architecture_status.keySet()) { Integer _total_cnt = architecture_total_builds.get(__val) Integer _failed_cnt = architecture_total_failed.get(__val) hudson.model.Result __result = architecture_status.get(__val) if (__result == Result.SUCCESS) { %>

${__val} - OK

${__val} - FAILED. ${_failed_cnt} out of ${_total_cnt} failed to build!

Toolchain Summary

<% for (String __val : toolchain_status.keySet()) { hudson.model.Result __result = toolchain_status.get(__val) Integer _total_cnt = toolchain_total_builds.get(__val) Integer _failed_cnt = toolchain_total_failed.get(__val) if (__result == Result.SUCCESS) { %>

${__val} - OK

${__val} - FAILED. ${_failed_cnt} out of ${_total_cnt} failed to build!

<% if (something_failed == true) { %>Information

A change you committed to a source repository MAY be responsible for breaking a build.
Review the data below or follow the link below to review the output of the build.
If your change was responsible for the build failure, fix ASAP.
If your change is not responsible, there is no need to respond to this email.
All developers with changes associated with this build failure will continue to be notified until the build succeeds.
All developers that are notified of a build failure will be informed by email when the build is once again successful.
Instructions to reproduce the build failure will follow.

<% for (hudson.matrix.MatrixRun run : runs) { if (run.getResult() != Result.SUCCESS) { String toolchain_val run_configuration = run.getParent() url = run.getUrl() configuration_combination = run_configuration.getCombination() toolchain = configuration_combination.get(toolchain_axis) architecture = configuration_combination.get(architecture_axis) toolchain_val = toolchain %>${toolchain_val} - ${architecture} Build Details

Build Output:

${rooturl}${url}/console

Reproduce:

ARCH=${architecture} XENV=${toolchain_val} make

 

<% } } } %>

--------------------------------

  1. In Default Content form in the email-ext configuration, I'm using FILE like ${FILE, path="/home/../../email.html"}
Any idea what i'm doing wrong?
thanks again
email-html

Slide

unread,
May 20, 2016, 3:10:02 AM5/20/16
to Jenkins Users

How are you using this in the project setup for email-ext?


--
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 jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/4819b18e-994f-4a68-845e-d2911b65834c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Antonio Hernandez

unread,
May 20, 2016, 3:20:10 AM5/20/16
to jenkins...@googlegroups.com
Hi, 
In Default Content form in the email-ext configuration, using FILE token to send the email directly ${FILE, path="email.html"}

But it not working because it's unable to resolve any of the variables... i have no idea how to make it works and resolve all the body 

Any idea?

Antonio Hernandez Pinto

Contact Me:



--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/66QcvqsV0c4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAPiUgVc67TR%2BPc%3DNfQY9L2uKRfJ8x6AHRbQGJw5ptXpe8iL1DQ%40mail.gmail.com.

Slide

unread,
May 20, 2016, 10:03:28 AM5/20/16
to jenkins...@googlegroups.com

It looks like you are trying to use groovy templates, which means you need to use ${SCRIPT, template="yourfile.html"}


Antonio Hernandez

unread,
May 23, 2016, 4:59:48 AM5/23/16
to jenkins...@googlegroups.com
Hi Slide,
I worked-around on it and i changed it with ${JELLY_SCRIPT,template="template"} because i'm using a .jelly template now and it's working.
Thanks a lot!

Antonio Hernandez Pinto

Contact Me:



Antonio Hernandez

unread,
May 23, 2016, 5:02:15 AM5/23/16
to Jenkins Users
Hi Slide,
I worked-around on it and i changed it with ${JELLY_SCRIPT,template="template"} because i'm using a .jelly template now and it's working.
Thanks a lot!



El jueves, 19 de mayo de 2016, 12:42:35 (UTC+2), Antonio Hernandez escribió:
Reply all
Reply to author
Forward
0 new messages