Can you get a build definition name from build result UUID?
I have a tool to update the properties (Last_Run) of a build definition after a completed build. There is nothing preventing teams from creating a build definition of the same name, so ensure we update the properties of the correct definition I would like to use the buildresultuuid to obtain the definition name. Are there any clues on how this can be done?
2 answers
Well it turns out RTC will prevent multiple build definitions with the same name, even accross project areas. This is great news, but it would still be nice if I could get the build definition name from the buildresultUUID. Otherwise, i have to go back and update just over a thousand definitions spread across five rtc instances.
I think something like this might do the trick:
ITeamRepository repo = getTeamRepository();
IItemManager itemManager = repo.itemManager();
UUID buildResultUUID = getBuildResultUUID();
IBuildResultHandle buildResultHandle = (IBuildResultHandle)IBuildResult.ITEM_TYPE.createItemHandle(
buildResultUUID,
null );
IBuildResult buildResult = (IBuildResult)itemManager.fetchPartialItem(
buildResultHandle,
IItemManager.DEFAULT,
Collections.singletonList( IBuildResult.PROPERTY_BUILD_DEFINITION ),
null );
IBuildDefinitionHandle buildDefnHandle = buildResult.getBuildDefinition();
IBuildDefinition buildDefn = (IBuildDefinition)itemManager.fetchPartialItem(
buildDefnHandle,
IItemManager.DEFAULT,
Collections.singletonList( IBuildDefinition.PROPERTY_ID ),
null );
System.out.println( buildDefn.getId() );
ITeamRepository repo = getTeamRepository();
IItemManager itemManager = repo.itemManager();
UUID buildResultUUID = getBuildResultUUID();
IBuildResultHandle buildResultHandle = (IBuildResultHandle)IBuildResult.ITEM_TYPE.createItemHandle(
buildResultUUID,
null );
IBuildResult buildResult = (IBuildResult)itemManager.fetchPartialItem(
buildResultHandle,
IItemManager.DEFAULT,
Collections.singletonList( IBuildResult.PROPERTY_BUILD_DEFINITION ),
null );
IBuildDefinitionHandle buildDefnHandle = buildResult.getBuildDefinition();
IBuildDefinition buildDefn = (IBuildDefinition)itemManager.fetchPartialItem(
buildDefnHandle,
IItemManager.DEFAULT,
Collections.singletonList( IBuildDefinition.PROPERTY_ID ),
null );
System.out.println( buildDefn.getId() );
Comments
Andrew Hoo
JAZZ DEVELOPER Dec 13 '12, 9:48 a.m.Daniel martin
Dec 13 '12, 10:31 a.m.