forked from cms-sw/cms-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleanup-cmssdt
executable file
·79 lines (68 loc) · 2.89 KB
/
cleanup-cmssdt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh -ex
DRY_RUN=$1
if [ "X$DRY_RUN" = "Xtrue" ] ; then
DRY_RUN=echo
else
DRY_RUN=
fi
JENKINS_ARTIFACTS=/data/sdt/SDT/jenkins-artifacts
DIRS_PROCESSED=
JOBS_TO_KEEP=150
RUNS_TO_KEEP=2
#Keep $JOBS_TO_KEEP of these
for dir in pull-request-integration cmsdist-pr ; do
[ -d ${JENKINS_ARTIFACTS}/$dir ] || continue
DIRS_PROCESSED="${DIRS_PROCESSED} ${dir}"
cd ${JENKINS_ARTIFACTS}/$dir
ls -rt | head -n -$JOBS_TO_KEEP | xargs -i --no-run-if-empty $DRY_RUN rm -rf '{}'
for run in `ls -d *`; do
ls -d $run/* | sed 's|.*/||' | sort -n | head -n -$RUNS_TO_KEEP | xargs -i --no-run-if-empty $DRY_RUN rm -rf "$run/{}"
done
done
RUNS_TO_KEEP=1
#Keep $JOBS_TO_KEEP of these with RUNS_TO_KEEP
for dir in baseLineComparisons ; do
[ -d ${JENKINS_ARTIFACTS}/$dir ] || continue
DIRS_PROCESSED="${DIRS_PROCESSED} ${dir}"
cd ${JENKINS_ARTIFACTS}/$dir
ls -rt | head -n -$JOBS_TO_KEEP | xargs -i --no-run-if-empty $DRY_RUN rm -rf '{}'
for run in `ls -d *`; do
ls -d $run/* | sed 's|.*/||' | sort -n | head -n -$RUNS_TO_KEEP | xargs -i --no-run-if-empty $DRY_RUN rm -rf "$run/{}"
done
done
JOBS_TO_KEEP=50
for dir in material-budget-ref ; do
[ -d ${JENKINS_ARTIFACTS}/$dir ] || continue
DIRS_PROCESSED="${DIRS_PROCESSED} ${dir}"
cd ${JENKINS_ARTIFACTS}/$dir
ls -rt | head -n -$JOBS_TO_KEEP | xargs -i --no-run-if-empty $DRY_RUN rm -rf '{}'
done
#Keep the following for 15 days
for dir in auto-build-release auto-upload-release cleanup-auto-build deploy-release-afs build-fwlite lizard; do
[ -d ${JENKINS_ARTIFACTS}/$dir ] || continue
DIRS_PROCESSED="${DIRS_PROCESSED} ${dir}"
find ${JENKINS_ARTIFACTS}/${dir} -mtime +15 -mindepth 1 -maxdepth 1 | xargs -i --no-run-if-empty $DRY_RUN rm -rf '{}'
done
#Keep the following for 60 days
for dir in run-pr-format pr-code-checks ; do
[ -d ${JENKINS_ARTIFACTS}/$dir ] || continue
DIRS_PROCESSED="${DIRS_PROCESSED} ${dir}"
find ${JENKINS_ARTIFACTS}/${dir} -mtime +60 -mindepth 1 -maxdepth 1 | xargs -i --no-run-if-empty $DRY_RUN rm -rf '{}'
done
#Keep the following for 8 days
for dir in valgrind HLT-Validation ib-static-analysis ib-baseline-tests ib-dqm-tests igprof iwyu material-budget das_query build-any-ib; do
[ -d ${JENKINS_ARTIFACTS}/$dir ] || continue
DIRS_PROCESSED="${DIRS_PROCESSED} ${dir}"
find ${JENKINS_ARTIFACTS}/${dir} -mtime +8 -mindepth 1 -maxdepth 1 | xargs -i --no-run-if-empty $DRY_RUN rm -rf '{}'
done
NEW_DIRS=""
for dir in `find ${JENKINS_ARTIFACTS} -mindepth 1 -maxdepth 1 -type d | sed 's|.*/||'`; do
if [ "X`echo ${DIRS_PROCESSED} | grep ${dir}`" = "X" ] ; then
NEW_DIRS="${NEW_DIRS} ${dir}"
fi
done
if [ "X${NEW_DIRS}" != "X" ] ; then
echo "New directories: ${NEW_DIRS}" | mail -s '[CMSSDT] Found new Directories to cleanup' cms-sdt-logs@cern.ch
fi
WEB_LOG_DIR=/data/sdt/buildlogs
find /data/sdt/buildlogs -mtime +8 -maxdepth 3 -maxdepth 3 -path '*/fwlite/CMSSW_*' -type d | xargs -i --no-run-if-empty $DRY_RUN rm -rf '{}'