Fetch build log from an IBuildResult object
Accepted answer
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).
Brent Ulbricht
RTC Build Lead
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
5 other answers
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
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
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
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);
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);