Brief Explanation
This even response will send an email to the specified recipients when a task execution fails.
Event Response Code
Add the following code as an event response to the 'Task Failure' event.
import velo.tools.EdmEmailSender; //extract data from context/initialize some informative variables def task = cntx.get("task"); String fromAddress = "email@yourdomain.com"; String taskStatus = task.getStatus(); if (taskStatus.equals("FATAL_ERROR")) { def et = tools.getEmailTemplate("TASK_FATAL_ERROR_ALERT"); et.addContentVar("task",task); String subject = "Task #" + task.taskId + " failure has occurred. " + task.description; log.trace("SCRIPTED: the subject is: "+subject); //Send email def eds = new EdmEmailSender(); eds.addHtmlEmail(fromAddress,et.recipientsEmailAddresses,subject,et.parsedContent); eds.send(); }
Email Template
Create a new email template, name it as TASK_FATAL_ERROR_ALERT and add the following content to it.
|
You must name the email template as TASK_FATAL_ERROR_ALERT |
<strong><font size="5" style="background-color: #ffffff" color="#ff0000"> <u><p><font size="5" style="background-color: #ffffff" color="#ff0000">Task Failure Execution has occured!</font></p></u> </font></strong><p><font size="2">There was a failure while trying to execute Task ID <strong>%task.taskId%</strong></font></p> <p><font size="2"><u>Following are some details of the task:</u></font></p> <p><u><font size="5" style="background-color: #ffffff" color="#ff0000"><strong> <table border="0" width="715" style="width: 715px; height: 100px; border: #0066cc 0px solid"><tbody><tr><td> <strong> Task ID</strong></td><td> %task.taskId%</td></tr><tr><td><strong> Failure Counts</strong></td> <td> %task.failureCounts%</td></tr><tr><td> <strong>Creation Date</strong></td><td> %task.creationDate%</td></tr> <tr><td><strong> Current Status</strong></td><td> %task.status%</td></tr><tr><td><strong> Task Description</strong></td> <td> %task.description%</td></tr><tr><td><font color="#ff0000"> <strong>Task Last Log Message</strong></font></td> <td> <font color="#ff0000">%task.lastLoggedErrorMessage%</font></td></tr></tbody></table></strong></font></u></p> <p>Link to task: <a href="http://VELOSERVER:8080/velo/admin/Task.seam?taskId=%task.taskId%">open task online page</a></p>
