Clean Versions

This script cleans all JCR versions from a specific workspace in Magnolia

import info.magnolia.cms.core.version.VersionManager;
import info.magnolia.context.MgnlContext;
import info.magnolia.jcr.util.NodeUtil;
import info.magnolia.jcr.util.NodeVisitor;
import javax.jcr.Session;
// specify which website you want to clean
String path = "/";
// specify which workspace you want to clean
String workspace = "website";
VersionManager vm = VersionManager.getInstance();
Session session =  MgnlContext.getJCRSession(workspace);
javax.jcr.Node root =session.getNode(path);
visitor = { node ->
NodeUtil.visit(root,  visitor as NodeVisitor);;