It's all about the answers!

Ask a question

Add Log To Build Result


Lachlan Hillman (36131) | asked Sep 05 '11, 12:28 a.m.
Hi,

I'm wondering if it's possible to add a log file to the build result? We get the default log, "Full Build Log", but I'd like to add another that comes out of the build so that it's easily accessible.

Is this possible if we aren't using Ant?

Thanks,
Lachlan Hillman.

14 answers



permanent link
Nick Edgar (6.5k711) | answered Sep 21 '11, 9:11 a.m.
JAZZ DEVELOPER
I've filed 178006: NPE in ValidatingX509TrustManager.initializeBaseTrustManager and subscribed you.

Some other things to check in the meantime:
- which JDK/JRE are you using? (see https://jazz.net/wiki/bin/view/Main/BuildFAQ#WhichJDK)
- are you running TeamPlatform.startup() as the first thing you do with the Jazz/RTC API?

permanent link
Lachlan Hillman (36131) | answered Sep 21 '11, 5:47 p.m.
I've filed 178006: NPE in ValidatingX509TrustManager.initializeBaseTrustManager and subscribed you.

Some other things to check in the meantime:
- which JDK/JRE are you using? (see https://jazz.net/wiki/bin/view/Main/BuildFAQ#WhichJDK)
- are you running TeamPlatform.startup() as the first thing you do with the Jazz/RTC API?


Thanks very much for filing the defect.

I believe I'm using the correct JDK version:

I've been pointing to the jdk that comes with the JBE (which has been used to access the same RTC server). For reference, this version is:

IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 Linux x86-32)


As for the code, I'm using the QueryBuildsWithTagExample found here: https://jazz.net/wiki/pub/Main/BuildJavaProgrammingExamples/QueryBuildsWithTagExample.java

Looks like it calls
TeamPlatform.startup();
before anything else.

permanent link
SEC Servizi (97123860) | answered Dec 21 '11, 4:32 a.m.
I'm wondering if it's possible to add a log file to the build result? We get the default log, "Full Build Log", but I'd like to add another that comes out of the build so that it's easily accessible.

Same request. :wink:

The Logs tab in the Eclipse UI has a button to add a log file and you already know of the Ant task. Another option is to use the Java API to code a program to add a log (which is essentially what the Ant task does).

Is it possible to do this with the REST API?
The Wiki page https://jazz.net/wiki/bin/view/Main/ResourceOrientedWorkItemAPIv2 has examples only for Work Item, not for Build at all!

We found the article https://jazz.net/library/article/195/ which states:
The Jazz build toolkit does not provide command line utilities for publishing status or artifacts. To achieve the same functionality in the Perl script, we have three options:
- Write a Java command line front end to the build API,
- Use an HTTP library (such as cURL) to fake access the build services directly,
- Wrap the existing Ant tasks in thin build scripts, and use those to publish.
The third option requires much less work than the other two, so we'll use that.

So, for now we are using the Ant task "artifactFilePublisher" in our scripts...

Thanks in advance.

permanent link
SEC Servizi (97123860) | answered Feb 06 '12, 5:00 a.m.
The essence of it is in com.ibm.team.build.internal.publishing.AbstractContributionPublisher.publish(IBuildResultHandle, BuildStatus, ITeamRepository) which does:

IBuildResultContribution contribution = BuildItemFactory.createBuildResultContribution();
contribution.setLabel(fLabel);
contribution.setImpactsPrimaryResult(true);
contribution.setStatus(contributionStatus);
contribution.setExtendedContributionTypeId(fExtendedContributionTypeId);

if (fComponentName != null) {
contribution.setComponentName(fComponentName);
}

initializeContribution(contribution, teamRepository);

ClientFactory.getTeamBuildClient(teamRepository).addBuildResultContribution(buildResultHandle, contribution,
null);

return contribution;


The contribution type id to use is com.ibm.team.build.common.model.IBuildResultContribution.LOG_EXTENDED_CONTRIBUTION_ID

initializeContribution comes from AbstractFilePublisher:

protected void initializeContribution(IBuildResultContribution contribution, ITeamRepository teamRepository)
throws TeamRepositoryException {

contribution.setExtendedContributionData(getFileContent(teamRepository));
contribution.setExtendedContributionProperty(IBuildResultContribution.PROPERTY_NAME_FILE_NAME, new File(
fFileLocation).getName());
}

and getFileContent (which creates the IContent blob from the file) is in ContentPublisher:

protected IContent getFileContent(ITeamRepository teamRepository) throws TeamRepositoryException,
TeamBuildException {
File file = new File(getFilePath());
IContent content = null;

try {
String contentType = getContentType();

if (ContentUtil.isTextContentType(contentType)) {
content = storeTextContent(contentType, file, teamRepository);
} else {
content = teamRepository.contentManager().storeContent(contentType, null,
LineDelimiter.LINE_DELIMITER_NONE, new FileInputStream(file), null, new NullProgressMonitor());
}
} catch (FileNotFoundException exception) {
throw new TeamBuildException(exception);
}

return content;
}

Hi Nick,
we have follow your steps and all works:
File file = new File("C:\foo.txt");

IContent content = teamRepository.contentManager().storeContent(IContent.CONTENT_TYPE_UNKNOWN, null, LineDelimiter.LINE_DELIMITER_NONE, new FileInputStream(file), null, null);
String label = //the description field
String componentName = //the component name

IBuildResultContribution contribution = BuildItemFactory.createBuildResultContribution();
contribution.setComponentName(componentName);
contribution.setLabel(label);
contribution.setExtendedContributionTypeId(IBuildResultContribution.ARTIFACT_EXTENDED_CONTRIBUTION_ID);
contribution.setExtendedContributionProperty(IBuildResultContribution.PROPERTY_NAME_FILE_NAME, file.getName());
contribution.setExtendedContributionData(content);

buildClient.addBuildResultContribution(buildResult, contribution, null);

Thank you for your help!

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.