How to programmatically check owner of snapshot is set to Stream.
Accepted answer
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:
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. }