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

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

I want to verify if build is promoted programmatically.

Requirement:
To delete build results that are not released.

 

0 votes


Accepted answer

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

0 votes

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
× 10,938
× 1,202
× 169

Question asked: Dec 12 '13, 12:34 p.m.

Question was seen: 5,271 times

Last updated: Dec 13 '13, 11:04 a.m.

Confirmation Cancel Confirm