Welcome to the Jazz Community Forum
API call to get RTC engine build activity

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
5 answers

IBuildResultSearchCriteria.BUILDER.forEngine(fBuildEngineHandle)
getRecordClient().getBuildResultRecords(buildQueryCriteria, buildResultProperties, monitor)
where getRecordClient() is:
fTeamRepository.getClientLibrary(ITeamBuildRecordClient.class);
com.ibm.team.build.internal.common.model.dto.IBuildResultSearchCriteria.inState(BuildState...)

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...
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.
|

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...
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()
.