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.What kind of "tool" do you have? Are you programming against the RTC SDK? If so, you may be able to fetch the build definition model from the repository. Otherwise, if you're using some other tool then I don't know.
*Note, I do not work on the build team - so I'm not sure what tools they provide, or whether anything that I would personally attempt in the SDK is sanctioned public api.
Daniel martin
Dec 13 '12, 10:31 a.m.Using the java api we created a jar that will update a build definition property. Currently the tool requires a property that provides the definition name. I would like to use the build result UUID to dynamically obtain that instead. As of yet I haven't found a way to do that