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

How to get the contents of the artifact download files in plain java api?


I got the iBuildResult object for the build in my java program, but how do i get a list of files published by the

artifactFilePublisher ant task. and the contents of each file. ?

 

I am running on RTC 3.0.1

 

Thanks.

 

 

 

 

0 votes


Accepted answer

Permanent link


i have got it working

IBuildResultQueryModel buildResultQueryModel = IBuildResultQueryModel.ROOT;

IItemQuery query = IItemQuery.FACTORY.newInstance(buildResultQueryModel);

query.filter(buildResultQueryModel._eq(query.newItemHandleArg()));

query.orderByDsc(buildResultQueryModel.buildStartTime());

ITeamBuildClient buildClient = ClientFactory.getTeamBuildClient(iTeamRepository);

UUID[] parameters = new UUID[1];

parameters[0]=UUID.valueOf("_A1h9oa47EeGW7pvup4pIzw");

IItemQueryPage queryPage = buildClient.queryItems(query, parameters, IQueryService.ITEM_QUERY_MAX_PAGE_SIZE,

monitor);

// print out the labels of the retrieved builds

String[] properties = new String[] { IBuildResult.PROPERTY_LABEL , IBuildResult.PROPERTY_BUILD_DEFINITION, IBuildResult.PROPERTY_TAGS, IBuildResult.PROPERTY_BUILD_RESULT_CONTRIBUTIONS,IBuildResult.PROPERTY_BUILD_REQUESTS};

List buildResults = iTeamRepository.itemManager().fetchPartialItems(queryPage.getItemHandles(),

IItemManager.DEFAULT, Arrays.asList(properties), monitor);

int nr=0;

for (Object result : buildResults) {

IBuildResult buildResult = (IBuildResult) result;

IBuildResultContribution[] buildresultContribution=buildClient.getBuildResultContributions((IBuildResultHandle) buildResult.getItemHandle(), IBuildResultContribution.ARTIFACT_EXTENDED_CONTRIBUTION_ID, monitor);

for (IBuildResultContribution iBuildResultContribution:buildresultContribution) {

System.out.println("label=" + iBuildResultContribution.getLabel());

IContent ic=iBuildResultContribution.getExtendedContributionData();

InputStream is=iTeamRepository.contentManager().retrieveContentStream(ic, monitor);

OutputStream os=new FileOutputStream("c:\\temp\\test.ear");

int c;

while ((c=is.read())!=-1) {

os.write(c);

}

is.close();

}

Ralph Schoon selected this answer as the correct answer

0 votes

Comments

Thanks for sharing!


One other answer

Permanent link
Hi Jan,

this might contain a pointer: https://jazz.net/library/article/807

In general I use the SDK and the Junit tests enclosed to understand how to get from one object to the next.

1 vote

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

Question asked: Jun 18 '12, 3:54 a.m.

Question was seen: 5,911 times

Last updated: Jul 04 '12, 6:08 a.m.

Confirmation Cancel Confirm