buildscripts: automatically delete versions older than 1hour, always succeed if reach end

This commit is contained in:
Spencer Fang 2017-12-28 13:03:53 -08:00 committed by zpencer
parent 692cffe763
commit d86647aebd
1 changed files with 3 additions and 2 deletions

View File

@ -81,6 +81,7 @@ set +e
echo "Cleaning out stale deploys from previous runs, it is ok if this part fails"
# Sometimes the trap based cleanup fails.
# Delete all versions older than 1 day. This expression is an ISO8601 relative date:
# Delete all versions older than 1 hour. This expression is an ISO8601 relative date:
# https://cloud.google.com/sdk/gcloud/reference/topic/datetimes
gcloud app versions list --format="get(version.id)" --filter="version.createTime<'-p1d'" | xargs -i gcloud app services delete $KOKORO_GAE_SERVICE --version {} --quiet
gcloud app versions list --format="get(version.id)" --filter="version.createTime<'-p1h'" | xargs -i gcloud app services delete $KOKORO_GAE_SERVICE --version {} --quiet
exit 0