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

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

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

0 votes



5 answers

Permanent link
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)

1 vote


Permanent link
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

0 votes


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

0 votes


Permanent link
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

0 votes


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

0 votes

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
× 10,941

Question asked: Jan 30 '12, 8:51 a.m.

Question was seen: 6,900 times

Last updated: Jan 30 '12, 8:51 a.m.

Confirmation Cancel Confirm