project-config/jenkins/scripts/slave-cleanup.sh
Andreas Jaeger 2035136b17 Rework slave-cleanup.sh
slave-cleanup.sh is run during translation jobs to cleanup the workspace
a bit.

It looks like it never did it job properly, since remove ~/.venv is the
wrong way.

Instead cleanup the local workspace:
* Report disk sizes to see whether this is worthwhile
* Run "git clean -f -x -d" to delete all extra files and directories

Change-Id: Ieae619a68a10b06976664e7e0cb53b31c6dfa658
2016-04-11 20:45:51 +02:00

26 lines
575 B
Bash

#!/bin/bash -xe
# Delete some files on slave at most once a day.
# Stores a marker file with date of last deletion.
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