Jazz Register Log in
Jazz Forum Welcome to the Jazz Community Forum

Welcome to the Jazz Community Forum

Connect and collaborate with IBM Engineering experts and users

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.



1 vote


Accepted answer

Permanent link
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

1 vote

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.

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 564

Question asked: Mar 19 '13, 9:31 a.m.

Question was seen: 4,263 times

Last updated: Mar 21 '13, 10:49 a.m.

Confirmation Cancel Confirm