It's all about the answers!

Ask a question

How to get the snapshot handle via Java API?


Jia Jia Li (8058157192) | asked Aug 25 '12, 5:51 a.m.
I should modify the build definition using the last day snapshot. 
I know the snapshot name, and how can I get the snapshot handle?

Thanks!

2 answers



permanent link
sam detweiler (12.5k6195201) | answered Aug 25 '12, 7:46 a.m.
I don't know, but this would probably be in the build toolkit

permanent link
Jia Jia Li (8058157192) | answered Sep 04 '12, 2:01 p.m.
The following code can work:
There is no snapshot class, instead of  IBaselineSet 
 
IWorkspaceManager wm = SCMPlatform.getWorkspaceManager(repo);
IItemQueryPage itemQueryPage = wm.findWorkspacesByName(stream, true,
true, false, 2, monitor);
if (itemQueryPage.getSize() == 0) {
return null;
}
IWorkspaceHandle workspaceHandle = (IWorkspaceHandle) itemQueryPage
.getItemHandles().get(0);
IWorkspaceConnection connection = null;
if (connection == null) {
            connection = SCMPlatform.getWorkspaceManager(repo).getWorkspaceConnection(workspaceHandle, null);
            connection.getName();
        }
List<IBaselineSetHandle> handles = connection.getBaselineSets(null);
handles.size();
        List<IBaselineSet> items = connection.teamRepository().itemManager().fetchCompleteItems(handles, IItemManager.DEFAULT, null);
        for(int i=0;i<items.size();i++){
        System.out.println(items.get(i).getName());
       
        }

Your answer


Register or 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.