Merge "Rework slave-cleanup"

This commit is contained in:
Jenkins 2016-04-13 14:52:02 +00:00 committed by Gerrit Code Review
commit 24daa741da

View File

@ -1,25 +1,11 @@
#!/bin/bash -xe
# Delete some files on slave at most once a day.
# Stores a marker file with date of last deletion.
# Cleanup workspace afterwards so that no extra files are in it.
# This is also done at beginning of each job but let's do it
# afterwards to save space on the workspace between invocations.
MARKER=.marker_CREATED
if [[ -f $MARKER ]] ; then
TODAY=$(date '+%Y%m%d')
# Delete only once a day
if [[ $(date -f $MARKER '+%Y%m%d') != $TODAY ]] ; then
# Let's see how much we delete.
# Let du report sizes each directory.
du -h --max-depth=1 .
git clean -f -x -d
du -h --max-depth=1 .
fi
fi
# Create marker file if it does not exist.
if [[ ! -f $MARKER ]] ; then
date '+%Y%m%d' > $MARKER
fi
# Let's see how much we delete.
# Let du report sizes each directory.
du -h --max-depth=1 .
git clean -f -x -d
du -h --max-depth=1 .