programmaticallypromoting a snapshot
![](http://jazz.net/_images/myphoto/f798cf7b8664ead44d18f1b187b0977c.jpg)
I would like to programmatically promote a good build snapshot from the build workspace to the default flow target (a stream). I have IWorkspaceConnection objects to both the build workspace and the stream and I can remove the IBaselineSet from the build workspace with:
However a cannot add the IBaselineSet to the stream with:
Is this the correct way to do a snapshot promotion? Why am I not able to see a snapshot added to a stream with the addBaselineSet method?
wsConn.removeBaselineSet(set, monitor);
However a cannot add the IBaselineSet to the stream with:
wsConn.addBaselineSet(set, monitor);
Is this the correct way to do a snapshot promotion? Why am I not able to see a snapshot added to a stream with the addBaselineSet method?
6 answers
![](http://jazz.net/_images/myphoto/f798cf7b8664ead44d18f1b187b0977c.jpg)
That should work just fine. You don't even need to remove the snapshot first -- it can be associated with multiple workspaces/streams.
The Promote action in the Search view when you Show Snapshots is implemented this way.
What error, if any, are you getting?
I actually figured out that I didn't need to make the call to remove and I only needed to do an add. Thanks for your help!
![](http://jazz.net/_images/myphoto/f798cf7b8664ead44d18f1b187b0977c.jpg)
I had a request for a code snippet on how this was actually accomplished. Note that this snippet is from a task that extends the AbstractTeamBuildTask class.
IWorkspaceManager workspaceManager = SCMPlatform.getWorkspaceManager(getTeamRepository());
IWorkspaceConnection workspaceConnection = workspaceManager.getWorkspaceConnection(workspace, getProgressMonitor());
IFlowTable flowTable = workspaceConnection.getFlowTable();
IFlowEntry flowEntry = flowTable.getCurrentDeliverFlow();
IWorkspace flowWorkspace = (IWorkspace)getTeamRepository().itemManager().fetchCompleteItem(flowEntry.getFlowNode(), IItemManager.REFRESH, getProgressMonitor());
IWorkspaceConnection flowConnection = workspaceManager.getWorkspaceConnection(flowWorkspace, getProgressMonitor());
List<IBaselineSet> snapshots = SourceControlUtility.getBaselineSets(getTeamRepository(), workspaceConnection, getProgressMonitor());
for(IBaselineSet set : snapshots){
if(set.getName().equals(snapshotName)){
flowConnection.addBaselineSet(set, getProgressMonitor());
break;
}
}
![](http://jazz.net/_images/myphoto/f798cf7b8664ead44d18f1b187b0977c.jpg)
This can also be done using the SCM command line (under scmtools in the RTC eclipse client install).
./scm.sh help snapshot promote
Help on snapshot promote
Promote snapshots to a workspace or stream. This will associate the snapshots with the workspace or stream.
Aliases: pr
Usage: scm snapshot promote <workspace> <snapshots>
workspace - Workspace or stream where the snapshots are promoted to.
snapshots - Snapshots to be promoted to the workspace or stream.
Options:
-P arg - Password for repository.
-r arg - URI specifying the location of repository.
-u arg - Username for repository.
./scm.sh help snapshot promote
Help on snapshot promote
Promote snapshots to a workspace or stream. This will associate the snapshots with the workspace or stream.
Aliases: pr
Usage: scm snapshot promote <workspace> <snapshots>
workspace - Workspace or stream where the snapshots are promoted to.
snapshots - Snapshots to be promoted to the workspace or stream.
Options:
-P arg - Password for repository.
-r arg - URI specifying the location of repository.
-u arg - Username for repository.
![](http://jazz.net/_images/myphoto/f798cf7b8664ead44d18f1b187b0977c.jpg)
Can you tell me what scm version you are using? I'm seeing:
Unknown subcommand "snapshot"
Here's my version:
/build/tools/IBM/TeamConcert/scmtools/eclipse/scm version
com.ibm.team.filesystem.cli.tools, version 2.0.2.I200910232005
Subcommands: tools.verify tools.validate tools.echo.stdin tools.configvalue
com.ibm.team.filesystem.cli.client, version 2.0.2.I200912072036
Subcommands: load login logout create create/workspace create/baseline create/changeset create/snapshot create/component changeset changeset/comment changeset/close changeset/relocate changeset/associate changeset/disassociate changeset/suspend changeset/resume daemon daemon/start daemon/stop change-target change-target/workspace change-target/component list list/workspaces list/projectareas list/teamareas list/streams list/components list/remotefiles list/credentials list/daemons list/snapshots list/locks list/properties checkin accept deliver status conflicts resolve move lastmod share discard undo compare history diff repair workspace workspace/add-components workspace/remove-components workspace/replace-components property property/list property/get property/set lock lock/list lock/acquire lock/release annotate
com.ibm.team.filesystem.cli.core, version 2.0.2.I200912032141
Subcommands: help version
Unknown subcommand "snapshot"
Here's my version:
/build/tools/IBM/TeamConcert/scmtools/eclipse/scm version
com.ibm.team.filesystem.cli.tools, version 2.0.2.I200910232005
Subcommands: tools.verify tools.validate tools.echo.stdin tools.configvalue
com.ibm.team.filesystem.cli.client, version 2.0.2.I200912072036
Subcommands: load login logout create create/workspace create/baseline create/changeset create/snapshot create/component changeset changeset/comment changeset/close changeset/relocate changeset/associate changeset/disassociate changeset/suspend changeset/resume daemon daemon/start daemon/stop change-target change-target/workspace change-target/component list list/workspaces list/projectareas list/teamareas list/streams list/components list/remotefiles list/credentials list/daemons list/snapshots list/locks list/properties checkin accept deliver status conflicts resolve move lastmod share discard undo compare history diff repair workspace workspace/add-components workspace/remove-components workspace/replace-components property property/list property/get property/set lock lock/list lock/acquire lock/release annotate
com.ibm.team.filesystem.cli.core, version 2.0.2.I200912032141
Subcommands: help version
![](http://jazz.net/_images/myphoto/f798cf7b8664ead44d18f1b187b0977c.jpg)
Can you tell me what scm version you are using? I'm seeing:
Unknown subcommand "snapshot"
Here's my version:
/build/tools/IBM/TeamConcert/scmtools/eclipse/scm version
com.ibm.team.filesystem.cli.tools, version 2.0.2.I200910232005
Subcommands: tools.verify tools.validate tools.echo.stdin tools.configvalue
com.ibm.team.filesystem.cli.client, version 2.0.2.I200912072036
Subcommands: load login logout create create/workspace create/baseline create/changeset create/snapshot create/component changeset changeset/comment changeset/close changeset/relocate changeset/associate changeset/disassociate changeset/suspend changeset/resume daemon daemon/start daemon/stop change-target change-target/workspace change-target/component list list/workspaces list/projectareas list/teamareas list/streams list/components list/remotefiles list/credentials list/daemons list/snapshots list/locks list/properties checkin accept deliver status conflicts resolve move lastmod share discard undo compare history diff repair workspace workspace/add-components workspace/remove-components workspace/replace-components property property/list property/get property/set lock lock/list lock/acquire lock/release annotate
com.ibm.team.filesystem.cli.core, version 2.0.2.I200912032141
Subcommands: help version
From Nick: It was only added in 3.0 M4: Want a promote snapshot for CLI (84638) However, you should be able to use the 3.0 M4 SCM CLI against a 2.0.0.x server. 3.0 M5 has version compatibility issues though.