Retrieving build history using Java API
4 answers
Hi Albin,
Somehow I missed the notification from your last comment. Sorry for the delay! I think you may want to try "buildResultQueryModel.buildDefinition()._eq(query.newItemHandleArg())" instead of "
Somehow I missed the notification from your last comment. Sorry for the delay! I think you may want to try "buildResultQueryModel.buildDefinition()._eq(query.newItemHandleArg())" instead of "
buildResultQueryModel._eq(buildDefinition.getItemHandle()"
. I'm including the code from a method I have that queries for an individual build based on its label and build definition in case it helps you:
IBuildResultQueryModel buildResultQueryModel = IBuildResultQueryModel.ROOT; IItemQuery query = IItemQuery.FACTORY.newInstance(buildResultQueryModel); query.filter( query.and(buildResultQueryModel.label()._like(query.newStringArg()), buildResultQueryModel.buildDefinition()._eq(query.newItemHandleArg()))); query.orderByDsc(buildResultQueryModel.buildStartTime()); IProgressMonitor monitor = new NullProgressMonitor(); ITeamBuildClient buildClient = (ITeamBuildClient) teamRepository.getClientLibrary(ITeamBuildClient.class); IBuildDefinition buildDefinition = buildClient.getBuildDefinition(buildDefinitionId, monitor); Object[] parameters = new Object[] { label, buildDefinition }; IItemQueryPage queryPage = buildClient.queryItems(query, parameters, IQueryService.ITEM_QUERY_MAX_PAGE_SIZE, monitor); if (queryPage.getSize() == 1) { return (IBuildResult) teamRepository.itemManager().fetchCompleteItems(queryPage.getItemHandles(), IItemManager.DEFAULT, monitor).get(0); } else { return null; }
Hi Lauren,
Thank you for your reply. I had a look into that code and I have created some code by following the examples. However it did not work for me. The code that I have today is given below.
TeamPlatform.startup();
IProgressMonitor monitor = new NullProgressMonitor();
ITeamRepository teamRepository = login("https://localhost:9443/jazz/", "user", "password", monitor);
ITeamBuildClient buildClient = (ITeamBuildClient) teamRepository .getClientLibrary(ITeamBuildClient.class);
IBuildDefinition buildDefinition = buildClient.getBuildDefinition("RTC_Deploy", monitor);
IBuildResultQueryModel buildResultQueryModel = IBuildResultQueryModel.ROOT;
IItemQuery query = IItemQuery.FACTORY.newInstance(buildResultQueryModel);
query.filter(buildResultQueryModel._eq(buildDefinition.getItemHandle()));
query.orderByDsc(buildResultQueryModel.buildStartTime());
String[] parameters = new String[] { };
IItemQueryPage queryPage = buildClient.queryItems(query, parameters, IQueryService.ITEM_QUERY_MAX_PAGE_SIZE, monitor);
System.out.println(queryPage.getItemHandles());
What I am doing wrong with the above code?
Thanks
-Albin
You might want to look into this article where I get the builds https://jazz.net/library/article/807. Maybe there is something new you can reuse.
What is the issue you are seeing with your expression?
What is the issue you are seeing with your expression?
Comments
And you might want to look at this post too, because that could be what you want: http://ryehle.wordpress.com/2012/06/28/custom-build-result-pruner/