UsingListenersin ScriptRunner for Bamboo, you can perform custom actions whenever standard Bamboo system events are fired. There are built-in listeners, or you can create a custom listener.
Adding a Listener
Navigate toAdmin>Listeners.
Select theAdd New Itembutton to expand the listeners available to create.
Choose aCustom Listeneror a built-in listener.
Custom Listeners
You can create custom listeners with your own scripts. To add a custom listener, follow these steps:
SelectCustom Listener.
In theEventsfield, select the events you want to listen for.
The event is contained in the script binding. The event object has the type corresponding to its name. For example, if you are listening forBuildCompletedEventyou get aBuildCompletedEventobject.
You may choose to have your listener look for multiple events. If you need to do different things depending on the type of event, you can check that withinstanceof.
Alternatively, you can type your event to the most specific superclass. In in the above example that would beBuildEvent.
For example, to get the page content for bothBuildCompletedEventandBuildDeletedEvent:
def event = event as BuildEvent// <1>
def content = event.content.bodyAsString
// do something with the page content
In the first line, the eventis passed in the binding. This line is only used to give type information when using an IDE, and has no functional impact.