It's all about the answers!

Ask a question

Build result Change event


Pancha Gyaneswari Yelika (45811) | asked Mar 19 '13, 9:31 a.m.
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


permanent link
Nick Edgar (6.5k711) | answered Mar 19 '13, 9:57 a.m.
JAZZ DEVELOPER
edited Mar 19 '13, 9:59 a.m.
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().
Pancha Gyaneswari Yelika selected this answer as the correct answer

Comments
Pancha Gyaneswari Yelika commented Mar 21 '13, 1:48 a.m.

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");


Nick Edgar commented Mar 21 '13, 10:49 a.m.
JAZZ DEVELOPER

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.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.