It's all about the answers!

Ask a question

How to read the Build Queue of a particular RTC Project.


Swapnonil Mukherjee (611) | asked Jan 30 '12, 8:51 a.m.
Hello Everybody,

I have created a RTC project and put a single component inside it. I have also created 2 build engines and a single build definition which is designated to be run on any of the two available build engines.

What I also want to do is to monitor the "Build Queue" of this project programmatically, and see whether there is an item in that queue which is in "pending" state.

I have download the Jazz SDK, and seen some examples of triggering builds but I still have not been able to figure this one out.

With Regards
Swapnonil Mukherjee

5 answers



permanent link
Nick Edgar (6.5k711) | answered Jan 31 '12, 5:18 p.m.
JAZZ DEVELOPER
Hi Swapnonil,

The one we use internally is:
com.ibm.team.build.internal.client.ITeamBuildRecordClient.getBuildResultRecords(IProjectAreaHandle, BuildState[], String[], IProgressMonitor):

    /**

* Get the build result records iterator for all build results in the given
* project area.
*
* @param projectAreaHandle
* The project area to search for build results.
* @param buildStates
* The build states to match. May be <code>null</code> or empty
* array to indicate all states.
* @param properties
* The properties to include in the returned build results.
* @param progressMonitor
* The progress monitor to track progress on or <code>null</code>
* if progress monitoring is not desired.
* @return A build result record iterator for all build results in the given
* project area.. May be empty, but never <code>null</code>.
* @throws TeamRepositoryException
* If an error occurs while accessing the repository.
*/
public IBuildResultRecordIterator getBuildResultRecords(IProjectAreaHandle projectAreaHandle,
BuildState[] buildStates, String[] properties, IProgressMonitor progressMonitor)
throws TeamRepositoryException;


The client interface can be obtained using:
com.ibm.team.repository.client.ITeamRepository.getClientLibrary(Class)

Note that this is internal though. To avoid using the internals, you'd need to construct your own query and use com.ibm.team.build.client.ITeamBuildBaseClient.queryItems(IItemQuery, Object[], int, IProgressMonitor)

permanent link
Krishna Kishore (50112) | answered Feb 15 '12, 3:39 a.m.
JAZZ DEVELOPER
Hi Nick,

Does the getBuildResultRecords return the queued builds ie even if the build is in pending sate(not started)? Their is a "getQueue" REST call
<repository>/jazz/resource/virtual/build/queue?projectAreaUUID=<item> &profile=REDUCED

which returns the items in the build queue. Is their a similar API on the Jazz SDK side or its subsumed by getBuildResultRecords.

Thanks
Kishore

permanent link
Nick Edgar (6.5k711) | answered Feb 15 '12, 9:49 a.m.
JAZZ DEVELOPER
Hi Kishore,

Yes, to see the build queue for the project, use that getBuildResultRecords with states BuildState.NOT_STARTED (aka pending) and BuildState.IN_PROGRESS.

permanent link
Swapnonil Mukherjee (611) | answered Feb 16 '12, 8:43 a.m.
Hi Everybody

The code that helped me browse the build queue is pasted below.


public static void queryPendingBuilds(ITeamRepository teamRepository)
throws TeamRepositoryException, URISyntaxException
{
ITeamBuildRecordClient buildRecordClient = (ITeamBuildRecordClient) teamRepository
.getClientLibrary(ITeamBuildRecordClient.class);
IProcessClientService processClient = (IProcessClientService) teamRepository
.getClientLibrary(IProcessClientService.class);

URI uri = URI.create("My Project".replaceAll(" ", "%20"));
IProjectArea projectArea = (IProjectArea) processClient.findProcessArea(uri, null, null);
BuildState[] states = { BuildState.NOT_STARTED };

String[] properties = new String[] { IBuildResult.PROPERTY_LABEL };

IProgressMonitor monitor = new NullProgressMonitor();
IBuildResultRecordIterator iterator = buildRecordClient.getBuildResultRecords(projectArea.getProjectArea(),
states, properties, monitor);
while (iterator.hasNext())
{
IBuildResultRecord record = iterator.next(monitor);
System.out.println(record.getBuildDefinition());
}
}

However I do not know if this is the best way do so.

With Regards
Swapnonil Mukherjee

permanent link
Nick Edgar (6.5k711) | answered Feb 16 '12, 9:11 a.m.
JAZZ DEVELOPER
That looks fine, except that we also show in-progress builds in the queue in the UI. Also, the use of internals isn't ideal.

Your answer


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