Files
EventHubBack/scripts/prune-ci-reports.sh
T

17 lines
610 B
Bash

#!/usr/bin/env bash
# Удаляет каталоги отчётов старше CI_REPORTS_KEEP_DAYS (default 14).
# Usage: prune-ci-reports.sh [/var/eventhub/ci-reports]
set -euo pipefail
ROOT="${1:-${CI_REPORTS_DIR:-/var/eventhub/ci-reports}}"
KEEP_DAYS="${CI_REPORTS_KEEP_DAYS:-14}"
if [[ ! -d "${ROOT}" ]]; then
echo "ci-reports: ${ROOT} отсутствует — пропуск"
exit 0
fi
echo "ci-reports prune: root=${ROOT} keep_days=${KEEP_DAYS}"
find "${ROOT}" -mindepth 2 -maxdepth 2 -type d -mtime "+${KEEP_DAYS}" -print -exec rm -rf {} + 2>/dev/null || true
echo "ci-reports prune: done"