Skip to content

Instantly share code, notes, and snippets.

@DeepDiver1975
Created November 20, 2018 11:26
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 DeepDiver1975/37e90accc38ae051983021531306b5b1 to your computer and use it in GitHub Desktop.
Save DeepDiver1975/37e90accc38ae051983021531306b5b1 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
if [ "$#" -lt 4 ]; then
echo "Illegal number of parameters"
echo "$0 <repo> <age> <page-from> <page-to>"
echo "Example: $0 owncloud/core 90 1 250"
exit
fi
repo=$1
age=$2
cutoff=$(date +"%s" -d "-$age days")
echo "Deleting logs for $repo which are older then $age days"
for I in $(seq $3 $4); do
echo Page $I
builds=$(curl -s https://drone.owncloud.com/api/repos/$repo/builds?page=$I | jq ".[] | select(.created_at < $cutoff) | .number")
for build in $builds; do
echo "curl -X 'DELETE' https://drone.owncloud.com/api/repos/$repo/logs/$build"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment