jenkins - write groovy email template to display parsed build errors in email body -


i using parsed console log plugin , email-ext plugin in jenkins send out daily build status, upon build failure or compiler warnings. display extracted error/warning message in email body. got groovy email template "https://github.com/jenkinsci/email-ext-plugin/blob/master/src/main/resources/hudson/plugins/emailext/templates/groovy-html.template". display console output instead of specific error/warning message want. have 0 knowledge on groovy or html et al, gonna take me sometime learn , able modify template fulfill need quickly.

can point me sample file can search out either console output or parsed console output , display lines contain "error" or "warning"?

any appreciated.

unfortunately, of html here quite ugly compatible outlook limited html support.

<%  def paddingfordepth(int depth) {     return "padding-left:${depth * 30}px"; }  def inserterrorpanerow(int depth, closure contents) {     %>         <tr class="${tablelineclass()}">             <td class="icon_cell"></td>             <td class="console_cell"></td>             <td class="phase_name_cell" style="${paddingfordepth(depth)}">                 <table width="100%" class="errorspane">     <%     contents()     %>                 </table>             </td>         </tr>     <% }  def insertconsolesummary(def build, int depth) {     if (build.result != hudson.model.result.failure)         return;      final beforesummary = 0     final summarystarted = 1     final summaryended = 2      bufferedreader logreader = new bufferedreader(build.getlogreader());     list<string> errorlines = new linkedlist<string>();     list<string> errorsummary = new linkedlist<string>();     boolean msbuilddetected = false;     int scanstage = beforesummary;      try     {         (string line = logreader.readline(); line != null; line = logreader.readline())         {             if (line.contains(' error ') || line.contains(' warning '))                 errorlines.add(line);              if (line.contains('microsoft (r) build engine version '))                 msbuilddetected = true;              if (msbuilddetected)             {                 switch (scanstage)                 {                 case beforesummary:                     if (line.equals('build failed.') || line.equals('build succeeded.'))                         scanstage = summarystarted;                     if (line.equals('attempting cancel build...'))                     {                         scanstage = summaryended;                         msbuilddetected = false;                     }                     break;                  case summarystarted:                     if (line ==~ /^\s*\d+ warning\(s\)/)                         scanstage = summaryended;                     else                         errorsummary.add(line);                     break;                 }             }         }     }         {         logreader.close();     }      if ((msbuilddetected && (errorsummary.size() > 0)) || (errorlines.size() > 0))     {         inserterrorpanerow(depth) {             %><tr><td><pre><%                 if (msbuilddetected)                     errorsummary.each { l -> println l }                 else                     errorlines.each { l -> println l }             %></pre></td></tr><%         }     } } %>  <style> .icon_cell { padding: 3px; padding-left: 5px; padding-right: 5px; height:16px; vertical-align:middle; } .console_cell { padding: 3px; padding-left: 5px; padding-right: 15px; height:16px; vertical-align:middle; } .phase_name_cell { height:16px; vertical-align:middle; } .errorspane { background-color:#ffe0e0; }  </style> <body> <!-- console output --> <table width="100%"> <tr><td class="bg1"><b>build summary</b></td></tr> </table> <br/>  <table border="0" class="phasestable"><tbody> <% insertconsolesummary(build, 0);  %> </tbody></table> <br/>  </body> 

Comments

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -