It's all about the answers!

Ask a question

Fetch build log from an IBuildResult object


Steve Woodruff (5132) | asked Jun 23 '11, 11:12 a.m.
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

Accepted answer


permanent link
Brent Ulbricht (2.5k11) | answered Jun 24 '11, 9:24 a.m.
JAZZ DEVELOPER
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

Comments
Nick Edgar commented Jul 15 '13, 1:36 p.m.
JAZZ DEVELOPER

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
Nick Edgar (6.5k711) | answered Jul 15 '13, 1:49 p.m.
JAZZ DEVELOPER
See also discussion in https://jazz.net/forum/questions/116496/retrieve-build-log

permanent link
Steve Woodruff (5132) | answered Jun 23 '11, 4:03 p.m.
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);

permanent link
Steve Woodruff (5132) | answered Jun 23 '11, 3:49 p.m.
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

permanent link
Steve Woodruff (5132) | answered Jun 23 '11, 3:47 p.m.
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

permanent link
Brent Ulbricht (2.5k11) | answered Jun 23 '11, 3:09 p.m.
JAZZ DEVELOPER
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

Your answer


Register or 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.