Skip to content

Instantly share code, notes, and snippets.

@ViktorOgnev
Created November 15, 2015 21:32
Show Gist options
  • Save ViktorOgnev/c5701b0109649e3eccac to your computer and use it in GitHub Desktop.
Save ViktorOgnev/c5701b0109649e3eccac to your computer and use it in GitHub Desktop.
python cleanup gcs repository
def cleanup_gcs():
branches = _get_git_branches()
project_bucket = '{}/{}'.format(env.ci.bucket, env.ci.project)
for obj in local(
'gsutil ls -R {}'.format(project_bucket), capture=True):
if any([branch in obj for branch in branches]):
continue
else:
local('gsutil -m rm -R {}'.format(obj))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment