Dashboard > Velo 1.0 > ... > Administration Guide > Task Failure Notification Event Response
Task Failure Notification Event Response
Added by Asaf Shakarchi, last edited by Asaf Shakarchi on Nov 13, 2008  (view change)
Labels: 
(None)


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>&nbsp;Task ID</strong></td><td>&nbsp;%task.taskId%</td></tr><tr><td><strong>&nbsp;Failure Counts</strong></td>
<td>&nbsp;%task.failureCounts%</td></tr><tr><td>&nbsp;<strong>Creation Date</strong></td><td>&nbsp;%task.creationDate%</td></tr>
<tr><td><strong>&nbsp;Current Status</strong></td><td>&nbsp;%task.status%</td></tr><tr><td><strong>&nbsp;Task Description</strong></td>
<td>&nbsp;%task.description%</td></tr><tr><td><font color="#ff0000">&nbsp;<strong>Task Last Log Message</strong></font></td>
<td>&nbsp;<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>

Site running on a free Atlassian Confluence Open Source Project License granted to Safehaus. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.4 Build:#809 Jun 12, 2007) - Bug/feature request - Contact Administrators