Question

I am using the RTC plugin in Jenkins to run our CI builds and as part of the build it creates a snapshot which is stored in the build RTC workspace. As far as I can tell there is no configuration option to disable the snapshot creation so we end up with hundreds of snapshots that we never need/use.

I'd like to have an automated way of deleting these snapshots so that I can then delete the old workspaces, but I can't find an option for that in the CLI - does anyone know how this could be done?

Thanks!

Was it helpful?

Solution

Those snapshot should be created only in the RTC repo workspace dedicated to the build (the repo workspace you associate to your Build Definition in RTC).

As mentioned in this thread

Snapshots cannot be delivered. It's an immutable configuration of a stream or workspace. It represents what went into your build.

You can delete the snapshot and it'll be in the build user's build workspace.

Even easier, you could delete/recreate that repo workspace.

But deleting only a few snapshots isn't advisable:

The snapshot represents the SCM workspace at the time of the build.
If changes were accepted, they would be included in this build, whether it passed or not, and the snapshot is used by build to report when the changesets were included into the build.

So deleting the snapshot would be inadvisable as it would confuse the build process in determining when changesets were actually introduced to the build.


However I need to periodically clean up the hundreds of build workspaces I have after they are no longer needed and I can't do that if there are snapshots in them

You could list those snapshots (right-click on the repo workspace, "Show snapshots") and see if a multiple selection of snapshots in that list allows you (through a contextual menu on said multiple selection) to delete them.

Or you can also, through the same multiple selection, change their ownership, to at least move them to a common repo workspace (to dump them in it, pending a more permanent solution)

But if you have hundreds of repos workspaces:

  • first, that is strange: your build Definition should reference only one, and Jenkins shouldn't build one, but simply receive the sources from RTC (unless you are not using RTC4)

  • second, you can list workspace, and for each one list their snapshots in order to delete those snapshots (using the Java API available in RTC downloads).
    See this thread

To remove the snapshots before deleting the workspace, call the following:

IWorkspaceConnection.removeBaselineSet(IBaselineSetHandle baselineSet, IProgressMonitor monitor)

If you have the IWorkspaceHandle of the workspace that owns the snapshots, you can find all snapshots that have that as the owner using IBaselineSetSearchCriteria (IBaselineSetSearchCriteria has methods to scope the query further).

Ex:

IWorkspaceHandle wsHandle = null // GET ME SOMEHOW
IWorkspaceManager workspaceManager = SCMPlatform.getWorkspaceManager(repo);
IBaselineSetSearchCriteria criteria = IBaselineSetSearchCriteria.FACTORY.newInstance();
criteria.setOwnerWorkspaceOptional(wsHandle);
List snapshotHandles = workspaceManager.findBaselineSets(criteria, MAX_TO_SHOW, null);
// snapshotHandles contains a list of IBaselineSetHandle, so you can fetch them
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top