Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

API call to get RTC engine build activity

Hello,

I was trying to get the number of builds in progress on RTC engine. The API call IBuildEngineActivityHandle.size() returns 69 for all engines. Please let me know if you saw this problem before. Here's my code snippet.

            teamRepository = TeamPlatform.getTeamRepositoryService()
                    .getTeamRepository(REPOSITORY_ADDRESS);
            teamRepository.registerLoginHandler(new LoginHandler(userId,
                    password));
            teamRepository.login(monitor);
           
            ITeamBuildClient buildClient = (ITeamBuildClient) teamRepository.getClientLibrary(ITeamBuildClient.class);
            IItemManager itemManager = teamRepository.itemManager();



IBuildEngine buildEngine=buildClient.getBuildEngine("RationalBuildforgeConnector", monitor);
       IBuildEngineActivityHandle ib=buildEngine.getBuildEngineActivity();
        System.out.println(ib.size());



Thanks
Sunil

0 votes



5 answers

Permanent link
 The build activities are all activities in all builds running on the engine.  So if you want builds running you want to gather the BuildResult and only those whose state is IN_PROGRESS.

~Spencer

0 votes


Permanent link
Hi Spencer,

Sorry, If I not being clear. I am looking to list active builds on the engine (right click engine - select Show Build Activity) via API call. Could you give some pointers?

Thanks
Sunil

0 votes


Permanent link
An IBuildEngineActivity item maintain the last contact time for an engine.  As with any other item, it's referenced by an item handle, in this case an IBuildEngineActivityItemHandle.  IItemHandle defines size(), but that's misleading -- it gives an estimate of the number of bytes taken by the handle's representation.

To get the list of active (i.e. in-progress) builds for a given build engine, you'd need to run an item query.
There's an internal query service method for builds that the Eclipse UI uses.  For example,
com.ibm.team.build.internal.ui.query.BuildQueryByEngine.getBuildQueryCriteria(IProgressMonitor)
returns:

  IBuildResultSearchCriteria.BUILDER.forEngine(fBuildEngineHandle)

where fBuildEngineHandle is an IBuildEngineHandle.
The criteria object is then passed to the query service method in:
  com.ibm.team.build.internal.ui.query.BuildQuery.doIterativeQuery(boolean, IProgressMonitor)
which does:

getRecordClient().getBuildResultRecords(buildQueryCriteria, buildResultProperties, monitor)

where getRecordClient() is:

fTeamRepository.getClientLibrary(ITeamBuildRecordClient.class);


The criteria object also lets you filter by build state:

com.ibm.team.build.internal.common.model.dto.IBuildResultSearchCriteria.inState(BuildState...)


Another option is to call:
  com.ibm.team.build.internal.client.ITeamBuildRecordClient.getBuildEngineStatusRecord(IBuildEngineHandle, IProgressMonitor)
where the resulting record lists the in-progress builds:
  com.ibm.team.build.internal.common.model.dto.IBuildEngineStatusRecord.getInProgressBuilds()
but this is also internal.

It's also possible to construct your own item query.  Although IBuildResultQueryModel lets you query for builds in a given state, the query model that's exposed as API does not let you filter by handling build engine (which is on the build's IBuildRequest item, not the IBuildResult).  Unfortunately, I don't see any way to do this with our current API.  Please feel free to open an enhancement request for this.



0 votes


Permanent link
Hi,

   Your suggestion above works very well to get IInProgressBuilds[] on a build engine.  With each IInProgressBuild record I can get the status.name(), the label(), and currentBuildActivityLabel().

    How do I get the StartTime and Duration of the build-in-progress (as also shows in Eclipse)?  Which objects do I need to traverse?  Do I somehow use the buildResult and then the fullState iItem?

    Thanks you for any tips.  I have looked very hard, but can not find a definitive answer to this.

    Al...

0 votes

Comments

everything is in the build result

long getBuildStartTime()
Get the time the build was started.
long getBuildTimeTaken()
Get the time taken by the build.


Permanent link
Excellent, thank you very much. 
I knew I was close, but I needed to correctly fetch the IBuildResult object.  This link helped bridge that gap: Fetch the data from the IBuildResultHandle

    public IBuildResult getBuildResult(IBuildResultHandle iBRH) throws TeamRepositoryException
    {
        IItemManager itemManager = teamRepository.itemManager();
        IBuildResult buildResultData = null;
     
        try{
            buildResultData = (IBuildResult)itemManager.fetchCompleteItem(iBRH, IItemManager.REFRESH, myPM);
        } catch(ItemNotFoundException infx) {
            logger.warn("RtcRepository.getBuildResult(), ItemNotFoundException, "+infx.getMessage());
        }
        return buildResultData;
    }

   And once done, your tip was perfect.  Since I am reading the running RTC build queue, the active jobs go away from the time I query the queue and the time I go to fetch the build data - so I catch the missing Item case.  And because I am looking at the active running builds, I guess I can't expect to have a BuildTimeTaken value.  I get zero for that call, and presumably would until the build completes?

   Thanks very much for your patience and information!

    Al...

0 votes

Comments

yes, if you have the handle to an object, you have to load the rest of the data. you can load everything ( .fetchCompleteItem) or only selected fields (.fetchItem)

time spent is not complete til the build ends,.. yes, but you can calculate it.
now- getBuildStartTime() .

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
× 562

Question asked: Mar 26 '13, 9:38 a.m.

Question was seen: 7,053 times

Last updated: May 18 '14, 6:35 a.m.

Confirmation Cancel Confirm