Dashboard > CruiseControl > Frequently Asked Questions > DeleteOldArtifactsWorkAround
DeleteOldArtifactsWorkAround Log In View a printable version of the current page.

Added by Chris Nappin , last edited by Owen carter on Apr 18, 2007  (view change) show comment
Labels: 

Deleting Old Artifacts

Time based

As a temporary work around (until CC supports deleting artifacts itself) you may want to add a cron job to delete builds over a set age.

Here is an example Unix shell script to do this:

#!/bin/sh

#
# Utility script that deletes CruiseControl build artifacts over a set age.
# Needed to prevent the disk becoming full. Designed to be invoked on a daily
# basis, e.g. from cron.
#
# Run as the cruise control user, to avoid wreaking havoc if it goes wrong.
#
# When CruiseControl supports deleting of build artifacts (like it does logs)
# then this script won't be needed.
#


# Set this to your CruiseControl Artifacts directory
ARTIFACTS_DIR=/home/build/cruisecontrol/cc-builds/artifacts

# Delete all artifacts over this age (days)
MAX_AGE=3


find $ARTIFACTS_DIR -mindepth 2 -maxdepth 2 -daystart -ctime +$MAX_AGE -exec rm -r '{}' \;

To run this script on a regular basis using cron, login as the user you are running CruiseControl as (ideally a non-privileged user) and run:

crontab -e

Here is an example cron setting to run the script at midnight every day, where "/home/build/cruisecontrol/delete-old-artifacts.sh" refers to the script above.

0 0 * * * /home/build/cruisecontrol/delete-old-artifacts.sh

Based on logfile existance.

If you have configured log file deletion through the <delete> element then an alternative approach is to periodically delete all artifacts that do not have a corresponding logfile entry (assuming you are comfortable loosing old artifacts this way).

The attached perl script, although not as elegant as a native CruiseControl or Java/Ant solution, will achieve this:

  • It can be run from a CruiseControl config, eg. as a <execute> action in <publishers>.
  • Written in perl because that is what I know; I developed it for use in-house at my company.
  • See the README in the archive for more notes, and use examples.
  • Has a debug and test mode to help when setting it up.
  • Bonus! it also cleans up the the logfile's _cache folder.
  Name Size Creator (Last Modifier) Creation Date Last Mod Date Comment  
ZIP Archive CruiseControl.ScrubArtifacts.zip 4 kb Owen carter Apr 18, 2007 Apr 18, 2007 Artifact Scrupper tool+readme

Future solutions

See the CruiseControl Jira; issue number CC-528.

I think lots of people achieve the same result by adding an additional project under CC that runs an ant script to remove the old artifacts.

Powered by a free Atlassian Confluence Open Source Project / Non-profit License granted to ThoughtWorks, Inc.. Evaluate Confluence today.
Powered by Atlassian Confluence 2.7.1, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators