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

Retrieving build history using Java API

Hi,

Is it possible to retrieve the build history using Java API?

Actually what I am trying to do is to find the name of the snapshots created by the last two builds. So I think the first step to do that is to retrieve the build history.

Thanks
-Albin

0 votes



4 answers

Permanent link
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 " 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;
}

1 vote


Permanent link
Hi Albin,
I'm not sure offhand how much information you can get about a build using the Java API.  https://jazz.net/wiki/bin/view/Main/BuildJavaProgrammingExamples has examples of how to query for builds, which may help you get started.

0 votes


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

0 votes

Comments

Hi Albin,
Can you explain how it did not work for you?

Its not retrieving any information. The list is empty.  I think there is something wrong with my query or filter. 


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

0 votes

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/

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
× 562
× 411
× 67

Question asked: Nov 06 '12, 10:46 a.m.

Question was seen: 5,700 times

Last updated: Nov 14 '12, 7:48 a.m.

Confirmation Cancel Confirm