It's all about the answers!

Ask a question

How do I access the build properties programmatically?

kanjbala jawahar (601815) | asked Apr 05 '14, 12:27 a.m.
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)?


sam detweiler commented Apr 05 '14, 8:23 a.m.

IBuildResult is another object. just like IBuildDefinition

you can search and find Build Results just like you do for Build Definitions.

IBuildResult->IBuildRequest->IBuildDefinition& Properties and ->IBuildEngine used & properties.

Build Def properties override build Engine properties of the same name.

kanjbala jawahar commented Apr 06 '14, 11:49 p.m.

I am not sure I understand the response above.
Yes, I understand that IBuildResult is an object just like any other.

From a build result object:
--one can get its build definition object and thus build definition properties
--one can also get the build engine and build engine properties
I understand all that and have done all that.

What I need is this:
--when I request a build (request build UI), I can change the values of properties under the "Build Properties" drop-down. I can remove/add properties. These changes are only for a "particular" instance, i.e. a build, not for the entire build definition. How do I get these properties "specific" to a build?

As you say, build definition properties override build engine properties of the same name.
In the case I have outlined above, I am overriding even build definition properties and could be adding/removing some on top of that. How do I "get" them?

Essentially, I need to "get" the properties and the corresponding values specific to a build result not of its build definition?


One answer

permanent link
kanjbala jawahar (601815) | answered Apr 09 '14, 4:04 p.m.
Ok. So I got the answer from this response by Nick Edgar:

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

Your answer

Register or to post your answer.