tidying up Ext-email output

90 views
Skip to first unread message

Ginga, Dick

unread,
Jun 10, 2016, 11:01:20 AM6/10/16
to jenkins...@googlegroups.com

Hello all, just trying to create a “better” email response.

 

I have some custom written tests that produce lots of test output, but I only want the failures (FAIL:) in the email,

 

09:53:06 *** FAIL: LTU_FUNC_TEST.LIBCFSEARCH_HITCOUNTTEST

09:54:09 *** FAIL: LTU_FUNC_TEST.LIBCFSEARCH_ATOMCENTER

09:54:15 *** FAIL: LTU_FUNC_TEST.LIBCFSEARCH_STRINGRESULT

 

so I use

 

${BUILD_LOG_REGEX, regex="(?i)( FAIL:.*)", substText="\n$1\n", showTruncatedLines=false, escapeHtml=true}

 

But I get this,

 

*** FAIL: LTU_FUNC_TEST.LIBCFSEARCH_HITCOUNTTEST *** FAIL: LTU_FUNC_TEST.LIBCFSEARCH_ATOMCENTER *** FAIL: LTU_FUNC_TEST.LIBCFSEARCH_STRINGRESULT

 

I would like each of these failures to be on its own line. That is what I thought maybe the substText might do but apparently not.

 

Is there a way to do this?

 

Dick Ginga, Informatics R&D

PerkinElmer Inc. | For the Better
HUMAN HEALTH | ENVIRONMENTAL HEALTH
940 Winter Street, Waltham MA 02451

 

dick.ginga@perkinelmer.com  

Mobile – 508-847-1434

Office – 781-663-6947

 

Slide

unread,
Jun 10, 2016, 11:15:08 AM6/10/16
to jenkins...@googlegroups.com

Are you using html email?


--
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/6C6EE445A6F6CE4E8A0FFB51B071A4E2D8711C23%40AMERMBX02.PERKINELMER.NET.
For more options, visit https://groups.google.com/d/optout.

Ginga, Dick

unread,
Jun 10, 2016, 11:19:00 AM6/10/16
to jenkins...@googlegroups.com

Slide

unread,
Jun 10, 2016, 11:20:33 AM6/10/16
to jenkins...@googlegroups.com

Have you tried using </br> instead of \n?


Ginga, Dick

unread,
Jun 10, 2016, 11:25:10 AM6/10/16
to jenkins...@googlegroups.com

I can try that. the tests run for 45 minutes…

 

But it looks to me like $1 is eval’ing to ALL 3 lines instead of EACH line

Ginga, Dick

unread,
Jun 10, 2016, 1:57:44 PM6/10/16
to jenkins...@googlegroups.com

I have tried <br> and escaped and not escaped HTML and <body> … </body> around my build-log-regex and I get this:

 

***<br> FAIL: LTU_FUNC_TEST.LIBCFSEARCH_HITCOUNTTEST ***<br> FAIL: LTU_FUNC_TEST.LIBCFSEARCH_ATOMCENTER ***<br> FAIL: LTU_FUNC_TEST.LIBCFSEARCH_STRINGRESULT

Ginga, Dick

unread,
Jun 10, 2016, 2:01:15 PM6/10/16
to jenkins...@googlegroups.com

The complete source of the email is:

 

meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style>

BODY, TABLE, TD, TH, P {

  font-family:Verdana,Helvetica,sans serif;

  font-size:11px;

  color:black;

}

h1 { color:black; }

h2 { color:black; }

h3 { color:black; }

TD.bg1 { color:white; background-color:#0000C0; font-size:120% }

TD.bg2 { color:white; background-color:#4040FF; font-size:110% }

TD.bg3 { color:white; background-color:#8080FF; }

TD.test_passed { color:blue; }

TD.test_failed { color:red; }

TD.console { font-family:Courier New; }

</style>

<body>

 

 

 

<table>

  <tr><td align="right"><img src="http://XXXXXXXX/static/e59dfe28/images/32x32/yellow.gif">

  </td><td valign="center"><b style="font-size: 200%;">BUILD UNSTABLE</b></td></tr>

  <tr><td>Build URL</td><td><a href="http://XXXXXXXX/job/Build-Run-CommonCS-Tests-Win/13/">http://XXXXXXXX/job/Build-Run-CommonCS-Tests-Win/13/</a></td></tr>

  <tr><td>Build Log</td><td><a href="http://XXXXXXXX/job/Build-Run-CommonCS-Tests-Win/13/console">http://XXXXXXXX/job/Build-Run-CommonCS-Tests-Win/13/console</a></td></tr>

  <tr><td>Project:</td><td>Build-Run-CommonCS-Tests-Win</td></tr>

  <tr><td>Date of build:</td><td>Fri, 10 Jun 2016 13:05:06 -0400</td></tr>

  <tr><td>Build duration:</td><td>30 min</td></tr>

  <tr><td>Stream:</td><td>null</td></tr>

  <tr><td>Build Number:</td><td>13</td></tr>

  <tr><td>Build Type:</td><td>null</td></tr>

</table>

<br>

 

<!-- CHANGE SET -->

 

                <table width="100%">

    <tr><td class="bg1" colspan="2"><b>CHANGES</b></td></tr>

               

        <tr><td colspan="2">No Changes</td></tr>

 

  </table>

<br>

 

 

<!-- ARTIFACTS -->

 

 

<!-- MAVEN ARTIFACTS -->

 

 

<!-- JUnit TEMPLATE -->

 

 

  </table>

<br>

 

<!-- CONSOLE OUTPUT -->

 

 

</body>

 

 

 

<body>

 

***&lt;br&gt; FAIL: LTU_FUNC_TEST.LIBCFSEARCH_HITCOUNTTEST

***&lt;br&gt; FAIL: LTU_FUNC_TEST.LIBCFSEARCH_ATOMCENTER

***&lt;br&gt; FAIL: LTU_FUNC_TEST.LIBCFSEARCH_STRINGRESULT

 

 

</body>

 

From: Ginga, Dick
Sent: Friday, June 10, 2016 1:57 PM
To: jenkins...@googlegroups.com
Subject: RE: tidying up Ext-email output

 

I have tried <br> and escaped and not escaped HTML and <body> … </body> around my build-log-regex and I get this:

 

***<br> FAIL: LTU_FUNC_TEST.LIBCFSEARCH_HITCOUNTTEST ***<br> FAIL: LTU_FUNC_TEST.LIBCFSEARCH_ATOMCENTER ***<br> FAIL: LTU_FUNC_TEST.LIBCFSEARCH_STRINGRESULT

 

 

 

Slide

unread,
Jun 10, 2016, 2:11:08 PM6/10/16
to jenkins...@googlegroups.com
Can you supply a larger amount of test from the build log that I can try locally?

Ginga, Dick

unread,
Jun 10, 2016, 2:16:14 PM6/10/16
to jenkins...@googlegroups.com

I don’t know what you consider large, but it all looks more or less like this:

 

13:08:49 CORE CHEM ERROR: CoordsAvail (a1, a2, a3) at line: 815, file: c:\builds\workspace\build-run-commoncs-tests-win\commoncs\libsdg\src\sdg_chains.cpp

13:08:49 CORE CHEM ERROR: CoordsAvail (a1, a2, a3) at line: 815, file: c:\builds\workspace\build-run-commoncs-tests-win\commoncs\libsdg\src\sdg_chains.cpp

13:08:49 CORE CHEM ERROR: CoordsAvail (a1, a2, a3) at line: 815, file: c:\builds\workspace\build-run-commoncs-tests-win\commoncs\libsdg\src\sdg_chains.cpp

13:08:49 CORE CHEM ERROR: CoordsAvail (a1, a2, a3) at line: 815, file: c:\builds\workspace\build-run-commoncs-tests-win\commoncs\libsdg\src\sdg_chains.cpp

13:08:49 CORE CHEM ERROR: CoordsAvail (a1, a2, a3) at line: 815, file: c:\builds\workspace\build-run-commoncs-tests-win\commoncs\libsdg\src\sdg_chains.cpp

13:08:49 CORE CHEM ERROR: CoordsAvail (a1, a2, a3) at line: 815, file: c:\builds\workspace\build-run-commoncs-tests-win\commoncs\libsdg\src\sdg_chains.cpp

13:08:49 CORE CHEM ERROR: CoordsAvail (a1, a2, a3) at line: 815, file: c:\builds\workspace\build-run-commoncs-tests-win\commoncs\libsdg\src\sdg_chains.cpp

13:08:49 CORE CHEM ERROR: m_at [0] != kccNoAb && m_at [0] < m_at [1] && m_at [1] < m_at [2] && (m_at [2] < m_at [3] || m_at [3] == kccNoAb) at line: 210, file: c:\builds\workspace\build-run-commoncs-tests-win\commoncs\libcc\src\cc_stereo.cpp

13:08:49    *** Value of: (int)queryHitSet.NumHits() |   Actual: 17 | Expected: numExpected | Which is: 1 | Hit count  failed for: test1.cdxml

13:08:49    *** Value of: (int)queryHitSet2.NumHits() |   Actual: 17 | Expected: numExpected | Which is: 1 | Hit count2 failed for: test1.cdxml

13:08:49 *** FAIL: LTU_FUNC_TEST.LIBCFSEARCH_HITCOUNTTEST

13:08:49 *** Starting test LTU_FUNC_TEST.LIBCFSEARCH_ATOMCENTER

13:08:49 CORE CHEM ERROR: m_fQuery || sopts.FullStruct() at line: 420, file: c:\builds\workspace\build-run-commoncs-tests-win\commoncs\libcc\src\cc_screens.cpp

13:08:49 CORE CHEM ERROR: CoordsAvail (a1, a2, a3) at line: 815, file: c:\builds\workspace\build-run-commoncs-tests-win\commoncs\libsdg\src\sdg_chains.cpp

13:08:49 CORE CHEM ERROR: CoordsAvail (a1, a2, a3) at line: 815, file: c:\builds\workspace\build-run-commoncs-tests-win\commoncs\libsdg\src\sdg_chains.cpp

13:08:49 CORE CHEM ERROR: CoordsAvail (a1, a2, a3) at line: 815, file: c:\builds\workspace\build-run-commoncs-tests-win\commoncs\libsdg\src\sdg_chains.cpp

13:08:49 CORE CHEM ERROR: CoordsAvail (a1, a2, a3) at line: 815, file: c:\builds\workspace\build-run-commoncs-tests-win\commoncs\libsdg\src\sdg_chains.cpp

13:08:49 CORE CHEM ERROR: CoordsAvail (a1, a2, a3) at line: 815, file: c:\builds\workspace\build-run-commoncs-tests-win\commoncs\libsdg\src\sdg_chains.cpp

13:08:49 CORE CHEM ERROR: CoordsAvail (a1, a2, a3) at line: 815, file: c:\builds\workspace\build-run-commoncs-tests-win\commoncs\libsdg\src\sdg_chains.cpp

Slide

unread,
Jun 10, 2016, 7:22:08 PM6/10/16
to jenkins...@googlegroups.com
Are you using a template for this? Or are you generating everything by hand using content tokens? If you are using a template, can you send it?

Ginga, Dick

unread,
Jun 13, 2016, 7:32:11 AM6/13/16
to jenkins...@googlegroups.com

I am using a template for the bulk of the email (attached). The actual Email Default Content field contains (at the moment)

 

$DEFAULT_CONTENT

 

<body>

 

${BUILD_LOG_REGEX, regex="(?i)( FAIL:.*)", escapeHtml=true, substText="<br>$1", showTruncatedLines=false, escapeHtml=true}

 

</body>

 

Thanks for your help.

core-build-model.jelly

Slide

unread,
Jun 13, 2016, 9:07:27 PM6/13/16
to jenkins...@googlegroups.com

This would create two body elements in the email, not sure how that will affect things.


Ginga, Dick

unread,
Jun 14, 2016, 7:42:37 AM6/14/16
to jenkins...@googlegroups.com

Well Slide, that was just my most recent attempt at getting the output I desire. I am still getting this as email output (fragment):

 



CHANGES

No Changes

Slide

unread,
Jun 14, 2016, 11:13:41 AM6/14/16
to jenkins...@googlegroups.com
I will try and test this out locally and see what I come up with.

Slide

unread,
Jun 14, 2016, 11:29:26 AM6/14/16
to jenkins...@googlegroups.com
FYI, the test you did with <br> shows that $1 is NOT evaluating to ALL three lines at once, since the <br> is in between each one. 

Ginga, Dick

unread,
Jun 14, 2016, 11:30:53 AM6/14/16
to jenkins...@googlegroups.com

Ginga, Dick

unread,
Jun 14, 2016, 11:41:33 AM6/14/16
to jenkins...@googlegroups.com

Hey Slide, if you would like to pursue this for academic reasons, feel free, but, we have just changed our tests to produce Junit formatted XML output and now my email looks like this. so I can now get rid of my attempt at capturing console test results.

 

Thanks a LOT for your help. I mean it.

 

 

CHANGES

No Changes



JUnit Tests

Name: (root) Failed: 3 test(s), Passed: 37 test(s), Skipped: 0 test(s), Total: 40 test(s)

·  Failed: LTU_FUNC_TEST.LIBCFSEARCH_ATOMCENTER

·  Failed: LTU_FUNC_TEST.LIBCFSEARCH_HITCOUNTTEST

·  Failed: LTU_FUNC_TEST.LIBCFSEARCH_STRINGRESULT

Slide

unread,
Jun 14, 2016, 11:42:42 AM6/14/16
to jenkins...@googlegroups.com
Ok, I think you actually want your regex to be this: (?i)(?:.*)(FAIL:.*)

The substText option replaces the content of only the matching portion of the string, so in your case, you are replacing the exact same text in the same spot. The regex above will match the entire line and only give back the "FAIL:..." portion of the message. In regards to the expansion, I am seeing the correct behavior with three lines separated by newline. If you are using a custom template, you can use the BUILD_LOG_REGEX token INSIDE the template to avoid any issues with HTML tags and so forth, you just use it a little differently:

BUILD_LOG_REGEX(regex: '...', substText: '...')

I think you want escapeHtml to be off and put <br> tags inside the substText to separate the lines that match.

I see you changed to a different output format, so the above doesn't apply, but I sent the email anyway so someone else may benefit in the future.

Ginga, Dick

unread,
Jun 14, 2016, 12:01:26 PM6/14/16
to jenkins...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages