Skip to content
This repository was archived by the owner on Apr 7, 2023. It is now read-only.

Commit e92cc19

Browse files
committed
Added script to clean out jenkins cottage builds
1 parent 781592f commit e92cc19

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

clean-old-jenkins-builds

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
4+
if [ -z "$1" ]; then
5+
exit 1;
6+
fi
7+
8+
BRAND_CODE=$1
9+
10+
JENKINS_HOME=`eval echo "~jenkins"`
11+
JENKINS_JOBS_DIR=$JENKINS_HOME/jobs/$BRAND_CODE/builds
12+
BUILDS_DIR=/var/www/html/$BRAND_CODE
13+
14+
for build in $BUILDS_DIR/jenkins*; do
15+
BUILD_NUM=$(echo $build | cut -d'-' -f3)
16+
JENKINS_BUILD_DIR=$JENKINS_JOBS_DIR/$BUILD_NUM
17+
ls $JENKINS_BUILD_DIR &> /dev/null
18+
BUILD_EXTST=$?
19+
if [ "$BUILD_EXTST" != 0 ]; then
20+
DB_NAME=`basename $build`
21+
rm -rf $build
22+
mysql-dropuser-and-db -u $DB_NAME
23+
fi
24+
done
25+

0 commit comments

Comments
 (0)