Welcome to the Jazz Community Forum
Build result Change event

Hi,
I am writing a Build Result Changed Event Handler Follow-up action using CLM 4.0.1.
public void handleEvent(IChangeEvent event,
IProcessConfigurationElement handlerConfiguration)
throws TeamRepositoryException {
}
How do I get the IBuilddefinition or the IBuildResult from the event triggered.
Accepted answer

Hi Pancha, a change event may have an associated item. Use IChangeEvent.getItem() to get its handle.
In the case of build events this is a build result handle, but could conceivably be something else so you should check before fetching it.
e.g.
if (event.getItem() instanceof IBuildResultHandle) {try {IBuildResult buildResult = (IBuildResult) getService(IRepositoryItemService.class).fetchItem(event.getItem(), IBuildResult.PROPERTIES_COMPLETE);} catch (ItemNotFoundException e) {...}...}
To get the definition, you'd fetch the IBuildDefinition whose handle is given by buildResult.getBuildDefinition().
It's possible that the result has been deleted between the time the event was generated and the time the event handler is called, so you need to handle that (i.e. the try/catch for ItemNotFoundException).
We also set some properties from the result and definition as string extensions on the change event, so it's possible to get this info even if the result has been deleted.
e.g.
String buildDefinitionId = event.getStringExtension("build.IBuildResult.buildDefinitionId");
You can find all string extensions on the event by casting the event down to com.ibm.team.repository.common.model.Item and calling getStringExtensions().
Comments

Thanks Nick, I have done accordingly and working fine.
Could I know from where we can find what are all the properties present.
And also could we get the the values for all the properties, related to the event using event.getStringExtension("propertyName");

The string extensions keys are: buildDefinitionId, status, state, label, requestorId, personalBuild, and tags. All prefixed by build.IBuildResult.
Constants for these are defined in our internal class com.ibm.team.build.internal.common.events.BuildResultEvent.