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
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
Hi Swapnonil,
The one we use internally is:
com.ibm.team.build.internal.client.ITeamBuildRecordClient.getBuildResultRecords(IProjectAreaHandle, BuildState[], String[], IProgressMonitor):
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)
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)
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
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
Hi Everybody
The code that helped me browse the build queue is pasted below.
However I do not know if this is the best way do so.
With Regards
Swapnonil Mukherjee
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