#
cd $TARGET_BASE/$TARGET_NAME
# loop through all results of current target
-for i in $(ls -at1) ; do
- # check if the jenkins build log still exists (and doesnt start with ".")
+for i in $(find . -maxdepth 1 -type d|sort) ; do
+ # check if the jenkins build log still exists (and $i != ".")
# and if not, delete the old target as well
- if [ ! -L $JOB_HOME/$i ] && [ "${i:0:1}" != "." ] ; then
+ if [ ! -L $JOB_HOME/$i ] && [ "${i}" != "." ] ; then
echo "Deleting $TARGET_BASE/$TARGET_NAME/$i"
sudo rm -r ./$i
fi