It's all about the answers!

Ask a question

How to programmatically check owner of snapshot is set to Stream.


Sanjeev Kulkarni (331220) | asked Dec 12 '13, 12:34 p.m.
retagged Dec 13 '13, 10:48 a.m. by David Lafreniere (4.3k7)
I want to verify if build is promoted programmatically.

Requirement:
To delete build results that are not released.

 

Accepted answer


permanent link
David Lafreniere (4.3k7) | answered Dec 13 '13, 11:00 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
edited Dec 13 '13, 11:04 a.m.
Hi Sanjeev.

I'm not sure exactly what you are trying to do, but I can provide some snippets that might be related which you can put together as needed.

To get the snapshot contribution of a particular build result:
  
protected IBaselineSet getSnapshotContribution(ITeamRepository teamRepository, IBuildResultHandle buildResultHandle, IProgressMonitor monitor) throws IllegalArgumentException, TeamRepositoryException {
   IBaselineSet baselineSet = null;
   ITeamBuildClient client = (ITeamBuildClient) getTeamRepository().getClientLibrary(ITeamBuildClient.class);
   IBuildResultContribution[] snapshotContribution = client.getBuildResultContributions(buildResultHandle, new String[] { ScmConstants.EXTENDED_DATA_TYPE_ID_BUILD_SNAPSHOT }, monitor);
   if (snapshotContribution.length > 0) {
      IBaselineSetHandle baselineSetHandle = (IBaselineSetHandle) snapshotContribution[0].getExtendedContribution();
      baselineSet = (IBaselineSet) getTeamRepository().itemManager().fetchCompleteItem(baselineSetHandle, IItemManager.REFRESH, monitor);
   }
  return baselineSet;
}
To check if the owner of the snapshot is a particular stream or workspace:

IWorkspaceHandle streamToCheck; // you'd have to retrieve the stream or workspace you care about somehow IBaselineSet snapshot = getSnapshotContribution(repo, build, monitor); // per the method above. if (!snapshot.getOwner().sameItemId(streamToCheck) { // Delete build result or what ever else you need to do. }
Sanjeev Kulkarni selected this answer as the correct answer

Your answer


Register or to post your answer.