Created
May 15, 2014 17:53
-
-
Save manisnesan/d2d8c6b9e70193b89ef5 to your computer and use it in GitHub Desktop.
Maven Housekeeping in Jenkins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# This script cleans up m2 repository SNAPSHOT jars that are older than specified $AGE days in Jenkins host. | |
# | |
# | |
M2_REPO=/usr/share/tomcat6/.m2 | |
OLDFILES=/tmp/oldfiles.txt | |
AGE=21 | |
echo "Starting M2 directory clean up " | |
find "${M2_REPO}" -name '*-SNAPSHOT*jar' -atime +${AGE} -exec dirname {} \; >> ${OLDFILES} | |
for x in `sort ${OLDFILES} | uniq`; do echo "Removing ${x}"; rm -rf "$x"; done | |
#Remove empty directories | |
find "${M2_REPO}" -type d -empty -exec rmdir {} \; >> ${OLDFILES} | |
rm ${OLDFILES} | |
echo "Done with M2 directory clean up" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment