Skip to content

Instantly share code, notes, and snippets.

@tomykaira
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomykaira/113fcbdb720121c8e6e1 to your computer and use it in GitHub Desktop.
Save tomykaira/113fcbdb720121c8e6e1 to your computer and use it in GitHub Desktop.
Remove RCov *.html files in /builds for Jenkins.
#!/bin/sh
# This simple shell script removes intermediate HTML files used by RCov and RubyMetrics plugin.
# RubyMetrics plugin extract data from HTML and save them to build.xml, so they are not used after tests are done.
# The HTML files are generated per tested file, then its number becomes enormous.
# Execute this script by cron or something to clean them up.
set -e
# Set this variable to the directory you want to cleanup
# example: /var/lib/jenkins/jobs/JOB_NAME/builds
BUILDS_DIR=''
[ -z $BUILDS_DIR ] && echo '$BUILDS_DIR is not set' && exit 1
IFS="
"
for old_dir in $(\ls -1Fu "$BUILDS_DIR" | awk -v curdir="$BUILDS_DIR/" 'match($0, "/$"){count++; if (count > 1) { print curdir $0 } }'); do
find $old_dir -maxdepth 1 -name "*.html" -delete
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment