How do I access the build properties programmatically?
The program that I am writing uses the RTC Plain Java API for 4.x.
I have gone over several forum posts that talk about accessing build definition properties.
But none for a build result or a build request.
When I bring up a build result, I see a lot of build properties, some left unchanged, some modified etc.
How do I "get" these properties as I can in the case of a build definition?
Essentially, how do I get the properties that a particular build instance actually used (which may be different from the ones defined as default in its build definition)?
Thanks.
I have gone over several forum posts that talk about accessing build definition properties.
But none for a build result or a build request.
When I bring up a build result, I see a lot of build properties, some left unchanged, some modified etc.
How do I "get" these properties as I can in the case of a build definition?
Essentially, how do I get the properties that a particular build instance actually used (which may be different from the ones defined as default in its build definition)?
Thanks.
One answer
Ok. So I got the answer from this response by Nick Edgar:
https://jazz.net/forum/questions/23094/retrieve-properties-from-a-build-request
Only thing to note is that the getProperties returns a List and not a Map (for this particular case). Not sure why.
A list of IBuildProperty objects.
So given a UUID string for an IBuildResult, here is what I do to get the properties that this particular build used:
UUID uuidObj = UUID.valueOf(str);
bldResultH = (IBuildResultHandle) IBuildResult.ITEM_TYPE.createItemHandle(uuidObj, null);
bldResult = (IBuildResult) repo.itemManager().fetchCompleteItem(bldResultH, IItemManager.DEFAULT, null);
List<IBuildRequestHandle> bReqHList = (List<IBuildRequestHandle>) bldResult.getBuildRequests();
for (IBuildRequestHandle brh : bReqHList) {
bReq = (IBuildRequest) repo.itemManager().fetchCompleteItem(brh, IItemManager.DEFAULT, null);
IBuildDefinitionInstance bdefIns = bReq.getBuildDefinitionInstance();
System.out.println("Properties for this instance: " + bdefIns.getProperties());
for (final Iterator<IBuildProperty> i = (bdefIns.getProperties()).iterator(); i.hasNext();) {
IBuildProperty bldProp = (IBuildProperty) i.next();
System.out.println(bldProp.getName() + "---------" + bldProp.getValue());
}
Hopefully the above will help somebody out.
I am not yet sure why the API has getBuildRequests and not just getBuildRequest. Isn't there a 1:1 relationship between a build and its build request?
https://jazz.net/forum/questions/23094/retrieve-properties-from-a-build-request
Only thing to note is that the getProperties returns a List and not a Map (for this particular case). Not sure why.
A list of IBuildProperty objects.
So given a UUID string for an IBuildResult, here is what I do to get the properties that this particular build used:
UUID uuidObj = UUID.valueOf(str);
bldResultH = (IBuildResultHandle) IBuildResult.ITEM_TYPE.createItemHandle(uuidObj, null);
bldResult = (IBuildResult) repo.itemManager().fetchCompleteItem(bldResultH, IItemManager.DEFAULT, null);
List<IBuildRequestHandle> bReqHList = (List<IBuildRequestHandle>) bldResult.getBuildRequests();
for (IBuildRequestHandle brh : bReqHList) {
bReq = (IBuildRequest) repo.itemManager().fetchCompleteItem(brh, IItemManager.DEFAULT, null);
IBuildDefinitionInstance bdefIns = bReq.getBuildDefinitionInstance();
System.out.println("Properties for this instance: " + bdefIns.getProperties());
for (final Iterator<IBuildProperty> i = (bdefIns.getProperties()).iterator(); i.hasNext();) {
IBuildProperty bldProp = (IBuildProperty) i.next();
System.out.println(bldProp.getName() + "---------" + bldProp.getValue());
}
Hopefully the above will help somebody out.
I am not yet sure why the API has getBuildRequests and not just getBuildRequest. Isn't there a 1:1 relationship between a build and its build request?
Comments
sam detweiler
Apr 05 '14, 8:23 a.m.kanjbala jawahar
Apr 06 '14, 11:49 p.m.