Event selectors are used to select events that trigger user notification.
Build provides a
selection of events that can trigger notification. The provided scripts examine events
and return a value of true if a notification is triggered, or false otherwise.
-
On the left navigational panel, click in the Notifications area.
-
Click Create Event Selector.
-
Using the New Event Selector page, type a name for the template in the
Name field.
-
Select the event that you want to use as a trigger from the Event Type
list.
The following list describes the event types that are provided with the product:
- Agent Status Changed triggers when an agent changes status, such as
Online or Offline.
- Build Deleted triggers when a workflow is deleted.
- Build Status Applied triggers when a build status is added or
changed.
- Build Request Failed or Build Not Needed triggers when a workflow fails
or does not start because of lack of source changes.
- Build Not Needed triggers when a workflow does not start because of lack
of source changes.
- Build Request Failed triggers when a workflow does not occur due to an
error in the build request.
- Workflow End triggers notifications when the workflow ends regardless of
status.
-
Enter the script in the Scripted box.
The script can be any JavaScript script that resolves to a true or false value.
The Workflow Status Change script triggers when a workflow ends successfully after the
previous invocation failed, or fails after the previous invocation was successful. This script is
one of the scripts that are provided with the
product.
var result = false;
var prevBuildLife = workflow.getBuildLife().getPrevious()
if (prevBuildLife == null) {
result = true
}
else {
var prevWorkflowCase = prevBuildLife.getWorkflow()
if (prevWorkflowCase == null || !prevWorkflowCase.isComplete() || prevWorkflowCase.statusIsSuccess() != workflow.statusIsSuccess()) {
result = true
}
}
result
-
Click Save.
Add the event selector to notification schemes, see Creating notification schemes.