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

Add Log To Build Result

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.

0 votes



14 answers

Permanent link
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?

0 votes


Permanent link
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.

0 votes


Permanent link
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.

0 votes


Permanent link
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!

0 votes

1–15 items
page 2of 1 pagesof 2 pages

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

Question asked: Sep 05 '11, 12:28 a.m.

Question was seen: 13,531 times

Last updated: Sep 05 '11, 12:28 a.m.

Confirmation Cancel Confirm