Version Differences for Notification Templates

(AHPSCRIPTS-23)
(AHPSCRIPTS-138)
Line 113:
  }     }  
  }</pre>    }</pre> 
       
    + = Include Error Messages in Notifications =  
       
    + *Post 3.4, it's become much easier to smartly include sections of the log that are interested in email notifications of failed builds or deployments. The API widgets that create those bright red error messages on the build life or job pages can be tapped into and used in the email. This example shows the changes to the context script you need to make, as well as a simple error reporting snippet that would work well in an html based email. It tries to be pretty minimal, but if you want more logging, you can remove some of the #if #end pairs.  
       
    + ==== AHPSCRIPTS-88 ====  
       
    + ''Context''  
    + <pre>import com.urbancode.anthill3.runtime.scripting.helpers.*;  
       
       
    + workflow = context.get("workflow");  
    + WorkflowErrorSummary wes = ErrorHelper.getWorkflowErrorSummary(workflow);  
    + int arrayLength = wes.getJobTraceErrorSummaryArray().length;  
    + context.put("workflowErrorSummary", wes);  
    + context.put("jtesal", arrayLength);</pre>  
       
    + ''Template''  
    + <pre>## BEGIN SECTION Subject  
       
    + Unit Testing  
       
    + ## END SECTION Subject  
       
    + ## BEGIN SECTION Body  
    + ## PROPERTY Content-Type: text/html  
    + ## PROPERTY X-Priority: 3  
       
    + #if ($workflowErrorSummary.logErrors ||  
    + $jtesal > 0)  
    + <h2> Workflow Error Log </h2>  
    + #if ($jtesal == 0)  
    + <pre>$workflowErrorSummary.logErrors</pre>  
    + #end  
    + #foreach($errorTrace in $workflowErrorSummary.jobTraceErrorSummaryArray)  
    + <h3>$errorTrace.jobName</h3>  
    + <pre>$errorTrace.logErrors</pre>  
    + <ul>  
    + #foreach($step in $errorTrace.stepTraceErrorSummaryArray)  
    + <li> <b>$step.stepName</b><br>  
    + #foreach($commandError in $step.commandTraceErrorSummaryArray)  
    + #if ($commandError.outputErrors)  
    + <pre>$commandError.outputErrors</pre>  
    + #else  
    + <pre>$commandError.logError</pre>  
    + #end  
    + <br><br>  
    + #end  
    + </li>  
    + #end  
    + </ul>  
    + #end  
    + #end  
       
    + ## END SECTION Body</pre>