It's all about the answers!

Ask a question

Fetching snapshot from BuildResult

Kelvin Lui (51299) | asked Dec 19 '12, 4:11 p.m.
edited Mar 28 '18, 12:09 p.m. by David Lafreniere (4.5k7)

 In RTC client someone could download the snapshot generated by the Build in the BuildResult page (there is a link to lead you to the snapshot).

I checked the IBuildResult class but couldn't find out any API associated with the snapshot.  Could someone show me the API to be used to fetch the snapshot created by specific Build?


Accepted answer

permanent link
David Lafreniere (4.5k7) | answered Mar 28 '18, 12:12 p.m.
edited Mar 28 '18, 12:15 p.m.

Here is how you retrieve the snapshot (IBaselineSetHandle) associated with a build result using the client-side Java API. (Note: I am assuming you already know the code used to fetch the full IBaselineSet from the IBaselineSetHandle):

   IBuildResultHandle buildResultHandle = getBuildResultHandle(); // This can be 'any' build result or 'release'
   IBaselineSetHandle snapshotHandle = null;
   ITeamBuildClient client = (ITeamBuildClient) getRepository().getClientLibrary(ITeamBuildClient.class);
   IBuildResultContribution[] contribution = client.getBuildResultContributions(buildResultHandle ,
      new String[] { ScmConstants.EXTENDED_DATA_TYPE_ID_BUILD_SNAPSHOT }, monitor);

   if (contribution.length > 0) { // It's possible for a build to NOT have a snapshot contribution
      snapshotHandle = (IBaselineSetHandle) contribution[0].getExtendedContribution();

Ralph Schoon selected this answer as the correct answer

2 other answers

permanent link
Ralph Schoon (57.1k23642) | answered Dec 19 '12, 6:16 p.m.
 It is very unclear what you are trying to do here is a hint on the API, however  Robins blog also mentions some interesting insight into the API .

Kelvin Lui commented Dec 19 '12, 11:41 p.m. | edited Mar 28 '18, 12:09 p.m.

 Thanks Ralph,  I have reviewed  but couldn't find any luck.

As far as I know when the build is complete a snapshot will be generated automatically and link to the build.

If someone search the build in RTC client, they can find the link to get this snapshot in the Overview tab -> Contribution Summary section.

I would like to find out the logic (api) how to fetch this snapshot associated with the specific build.

Hope that clarifies. 


permanent link
Stefan Sauterleute (283) | answered Feb 22 '18, 10:14 a.m.
I would like to reactivate this question:

Is there any opportunity to fetch a snapshot from a release via java plain api?

Ralph Schoon commented Feb 23 '18, 3:26 a.m. | edited Mar 28 '18, 12:09 p.m.

It does not make sense to "reactivate" a 6 years old question. Anyway, if the release was created from a build you can open the build result from the release in the Eclipse client and from the build result you can get at the snapshot, It is available in the Eclipse client, so the likelihood to be able to do this using the plain java API is pretty high. It might use internal API. I have no example code.

Your answer

Register or to post your answer.