summaryrefslogtreecommitdiffstats
path: root/jjb/apex/apex-gs-cleanup.sh
diff options
context:
space:
mode:
Diffstat (limited to 'jjb/apex/apex-gs-cleanup.sh')
-rwxr-xr-xjjb/apex/apex-gs-cleanup.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/jjb/apex/apex-gs-cleanup.sh b/jjb/apex/apex-gs-cleanup.sh
new file mode 100755
index 000000000..1629aa85e
--- /dev/null
+++ b/jjb/apex/apex-gs-cleanup.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+set -o errexit
+set -o nounset
+set -o pipefail
+
+# log info to console
+echo "Cleaning Google Storage"
+echo "-----------------------"
+echo
+
+thirty_days_ago=$(date -d "30 days ago" +"%Y%m%d")
+
+for i in $(gsutil ls gs://$GS_URL/*201?*); do
+ filedate=$(date -d "$(echo $i | grep -Eo 201[0-9]-?[0-9][0-9]-?[0-9][0-9])" +"%Y%m%d")
+ if [ $filedate -lt $thirty_days_ago ]; then
+ # gsutil indicates what it is removing so no need for output here
+ gsutil rm $i
+ fi
+done