Skip to content

Instantly share code, notes, and snippets.

@xlcommunity
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xlcommunity/6cb133540651f3b6abc9 to your computer and use it in GitHub Desktop.
Save xlcommunity/6cb133540651f3b6abc9 to your computer and use it in GitHub Desktop.
Delete all application package revisions before a specified one
# THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS
# FOR A PARTICULAR PURPOSE. THIS CODE AND INFORMATION ARE NOT SUPPORTED BY XEBIALABS.
# usage : provide Application Package ID as "Applications/MyApp/1.0.39" as the first parameter
# usage : bin/cli.sh -expose-proxies -username <user> -password <pass> -f cleanRevisions.py "Applications/MyApp/1.0.39"
import sys
yourDP = sys.argv[1]
for revision in proxies.getHistoryService().readRevisions(yourDP):
if revision.getRevisionName() == "current" :
yourRevTime = revision.getCreatedAt().getTimeInMillis()
print "Deleting all revisions before this Revision : " + yourDP
packages = repository.search("udm.DeploymentPackage",yourDP.rpartition("/")[0])
for package in packages:
for revision in proxies.getHistoryService().readRevisions(package):
if revision.getRevisionName() == "current" :
revTime = revision.getCreatedAt().getTimeInMillis()
if revTime < yourRevTime:
print "This package : " + package + " is being deleted"
repository.delete(package)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment