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

Fetch build log from an IBuildResult object

Is there an easy way to find the build log (link to it or the log itself) when we have an IBuildResult object?

Thanks!

-Steve

0 votes


Accepted answer

Permanent link
Hi Steve,

You're right about getting the IDs. This is a way to get them, but getting the contribution's UUID does cast down to an internal class (which could change in the future).


IProgressMonitor monitor = new NullProgressMonitor();
ITeamRepository teamRepository = login(repositoryURI, userId, password, monitor);

ITeamBuildClient buildClient = (ITeamBuildClient) teamRepository.getClientLibrary(ITeamBuildClient.class);
IBuildDefinition buildDefinition = buildClient.getBuildDefinition(buildDefinitionId, monitor);

IBuildResult buildResult = buildClient.getLastBuildResult(buildDefinition,
new BuildState[] { BuildState.COMPLETED }, IBuildResult.PROPERTIES_COMPLETE, monitor);

IBuildResultContribution[] contributions = buildClient.getBuildResultContributions(buildResult,
IBuildResultContribution.LOG_EXTENDED_CONTRIBUTION_ID, monitor);

System.out.println("!!!! " + buildResult.getItemId().getUuidValue() + " !!!!");

System.out.println("#### " + ((BuildResultContribution) contributions[0]).getInternalId().getUuidValue() + " ####");

System.out.println("**** " + contributions[0].getExtendedContributionProperty(IBuildResultContribution.PROPERTY_NAME_FILE_NAME) + " ****");


Brent Ulbricht
RTC Build Lead
Steve Woodruff selected this answer as the correct answer

0 votes

Comments

To avoid the internal ref to BuildResultContribution, you could instead cast to com.ibm.team.repository.common.model.Helper, which provides the getInternalId() method. 


5 other answers

Permanent link
Is there an easy way to find the build log (link to it or the log itself) when we have an IBuildResult object?

Thanks!

-Steve


Hi Steve,

You could do something along these lines.


IProgressMonitor monitor = new NullProgressMonitor();
ITeamRepository teamRepository = login(repositoryURI, userId, password, monitor);

ITeamBuildClient buildClient = (ITeamBuildClient) teamRepository.getClientLibrary(ITeamBuildClient.class);
IBuildDefinition buildDefinition = buildClient.getBuildDefinition(buildDefinitionId, monitor);

IBuildResult buildResult = buildClient.getLastBuildResult(buildDefinition,
new BuildState[] { BuildState.COMPLETED }, IBuildResult.PROPERTIES_COMPLETE, monitor);

IBuildResultContribution[] contributions = buildClient.getBuildResultContributions(buildResult,
IBuildResultContribution.LOG_EXTENDED_CONTRIBUTION_ID, monitor);

System.out.println("**** " + contributions[0].getExtendedContributionProperty(IBuildResultContribution.PROPERTY_NAME_FILE_NAME) + " ****");


Brent Ulbricht
RTC Build Lead

0 votes


Permanent link
Hi Brent - Thanks for the reply. I'm able to get the name of the log with the code you supplied but its not quite what I'm looking for.

I've tried with: PROPERTY_NAME_FILE_NAME, PROPERTY_NAME_URL, PROPERTY_NAME_FILE_PATH ... but they're all null except for PROPERTY_NAME_FILE_NAME, and that's just a relative path like build-1308857481749.log.

Is there a way to compose the url to the log that can be passed on to a user or fetched via browser?

Thanks!

-Steve

0 votes


Permanent link
A typical URL for the log would be like:

https://rtc01....../jazz/resource/virtual/build/result/_u11NsZ1VEeCO-eRZAbDMnQ/contribution/_CC5fgJ1WEeCO-eRZAbDMnQ/build-1308805236565.log

So its a matter of filling in those IDs before and after /contribution/ ...

Thanks!

-Steve

0 votes


Permanent link
Am I seeing these nulls because I am not fetching the correct items ? I'm doing a partial fetch as follows:



String[] properties = new String[] { IBuildResult.PROPERTY_LABEL, IBuildResult.PROPERTY_BUILD_STATUS,
IBuildResult.PROPERTY_BUILD_STATE, IBuildResult.PROPERTY_BUILD_TIME_TAKEN,
IBuildResult.PROPERTY_PERSONAL_BUILD, IBuildResult.PROPERTY_BUILD_DEFINITION,
IBuildResult.PROPERTY_SUMMARY, IBuildResult.PROPERTY_BUILD_ACTIVITIES,
IBuildResult.PROPERTY_TAGS, IBuildResult.PROPERTY_BUILD_RESULT_CONTRIBUTIONS };

List<?> buildResults = teamRepository.itemManager().fetchPartialItems(queryPage.getItemHandles(),
IItemManager.DEFAULT, Arrays.asList(properties), monitor);

0 votes


Permanent link
See also discussion in https://jazz.net/forum/questions/116496/retrieve-build-log

0 votes

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
× 10,922

Question asked: Jun 23 '11, 11:12 a.m.

Question was seen: 7,587 times

Last updated: Jul 15 '13, 1:49 p.m.

Confirmation Cancel Confirm