NOW="$(date +"%s")"
-counter=0
-for build in $(find "${BASEDIR}" -mindepth 2 -maxdepth 2 -type d | sort -nr); do
- time="$(basename "${build}")"
- [ "${time}" = "latest" ] && continue
-
- # Never delete the last two builds
- if [ "${counter}" -lt 2 ]; then
- counter=$(( ${counter} + 1 ))
- continue
- fi
-
- # Determine age of the build
- change="$(stat --format="%Y" "${build}")"
- age=$(( ${NOW} - ${change} ))
-
- # If the build is old enough we will delete it
- if [[ ${age} -ge ${MAX_AGE} ]]; then
- rm -rf "${build}"
- fi
+for branch in $(find "${BASEDIR}" -mindepth 1 -maxdepth 1 -type d); do
+ counter=0
+
+ for build in $(find "${branch}" -mindepth 1 -maxdepth 1 -type d | sort -nr); do
+ time="$(basename "${build}")"
+ [ "${time}" = "latest" ] && continue
+
+ # Never delete the last two builds
+ if [ "${counter}" -lt 2 ]; then
+ counter=$(( ${counter} + 1 ))
+ continue
+ fi
+
+ # Determine age of the build
+ change="$(stat --format="%Y" "${build}")"
+ age=$(( ${NOW} - ${change} ))
+
+ # If the build is old enough we will delete it
+ if [[ ${age} -ge ${MAX_AGE} ]]; then
+ rm -rf "${build}"
+ fi
+ done
done
exit 0