How to get the ITeamBuildService
Hi, I use the following code to get the ITeamBuildService, but it has null value. the pa object is gotten.
Do I use the wrong API? Please help. Thanks!
ITeamRepository repo = login(monitor);
IProjectArea pa = getProjArea(repo,monitor);
ITeamBuildService service = (ITeamBuildService) repo.getClientLibrary(ITeamBuildService.class);
IBuildDefinition[] buildDefs = service.getBuildDefinitions();
Accepted answer
ok, here is the routine which will get the current set of build engines from a repo
ugly programming model. this returns all the properties of each build engine.
one could reduce the data if desired, by removing some of the properties in the
all_properties list
also provided is a routine to filter that by a specific project area.
this needs the process_area property to be returned
private void processBuilds(ITeamRepository repo, IProjectArea owning_project)
{
for (IBuildEngine buildEngine : getBuildEngines(repo)) {
if(buildEngine.getProcessArea().sameItemId(owning_project))
System.out.println(buildEngine.getId()+ " = "+ buildEngine.getDescription());
}
}
private ArrayList<IBuildEngine> getBuildEngines(ITeamRepository repo)
{
// allocate space for results
ArrayList<IBuildEngine> allbe=new ArrayList<IBuildEngine>();
// get the data interface
ITeamBuildClient buildClient = (ITeamBuildClient) repo
.getClientLibrary(ITeamBuildClient.class);
try
{
IBuildEngineQueryModel queryModel = IBuildEngineQueryModel.ROOT;
// create a query for build engines
IItemQuery query = IItemQuery.FACTORY.newInstance(queryModel);
// objects of build engine type
IPredicate isBuildEngineType = queryModel._isTypeOf(IBuildEngine.ITEM_TYPE);
// the query filter
query.filter(isBuildEngineType);
// no parameters required
IItemQueryPage queryPage = buildClient.queryItems(query,
com.ibm.team.repository.common.service.IQueryService.EMPTY_PARAMETERS,
IQueryService.ITEM_QUERY_MAX_PAGE_SIZE, null);
// if there are buildengines defined
if (queryPage.getResultSize() != 0) {
while (queryPage != null) {
// print out a page of IDs of the retrieved build engines
final String[] all_properties = new String[] {
IBuildEngine.PROPERTY_ACTIVE,
IBuildEngine.PROPERTY_BUILD_ENGINE_ACTIVITY,
IBuildEngine.PROPERTY_DESCRIPTION,
IBuildEngine.PROPERTY_ENGINE_CONTACT_INTERVAL,
IBuildEngine.PROPERTY_ID ,
IBuildEngine.PROPERTY_PROCESS_AREA,
IBuildEngine.PROPERTY_SUPPORTED_BUILD_DEFINITIONS,
IBuildEngine.PROPERTY_SUPPORTS_CANCELLATION,
IBuildEngine.PROPERTY_USE_TEAM_SCHEDULER,
IBuildEngine.PROPERTY_PROPERTIES,
IBuildEngine.PROPERTY_CONFIGURATION_ELEMENTS
};
IFetchResult fetchResult = repo.itemManager().fetchPartialItemsPermissionAware(queryPage.getItemHandles(), IItemManager.DEFAULT,
Arrays.asList(all_properties), null);
// add these to the list
allbe.addAll(fetchResult.getRetrievedItems());
if (queryPage.hasNext()) {
queryPage = (IItemQueryPage) buildClient.fetchPage(queryPage.getToken(), queryPage.getNextStartPosition(), queryPage.getSize(), null);
} else {
queryPage = null;
}
}
}
}
catch (Exception ex)
{
System.out.println("build exception="+ex.getMessage());
}
return allbe;
}
Comments
2 other answers
Jia, please download the javadoc for the Plain Java Client Libraries. You will notice that the service you refer to is not available there. It is a server side service. So you can't get it as a client library. See https://jazz.net/library/article/807 for more information on the API.
I would assume you have to use the ITeamBuildClient.
I would assume you have to use the ITeamBuildClient.
Comments
Jia,
please have a look into the JavaDoc of the Plain Java client library and try to use the basic search functionality in the Eclipse PDE with Eclipse set up for SDK and Plain Java development (see my article on how to).
I could find a method to get the build definitions from the ITeamBuildClient in less than 3 minutes. This is a client library that you cen get using getClientLibrary().
please have a look into the JavaDoc of the Plain Java client library and try to use the basic search functionality in the Eclipse PDE with Eclipse set up for SDK and Plain Java development (see my article on how to).
I could find a method to get the build definitions from the ITeamBuildClient in less than 3 minutes. This is a client library that you cen get using getClientLibrary().
Comments
showing 5 of 7
show 2 more comments