Last active
August 29, 2015 14:16
-
-
Save xlcommunity/6cb133540651f3b6abc9 to your computer and use it in GitHub Desktop.
Delete all application package revisions before a specified one
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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