put remove actions outside the loop

This commit is contained in:
Roberto Cirillo 2022-10-04 10:59:41 +02:00
parent 360a7cf5be
commit 350b9ccb8c
1 changed files with 14 additions and 10 deletions

24
Jenkinsfile vendored
View File

@ -112,6 +112,7 @@ pipeline {
if (files == null){
println ("Nothing to do");
}else{
def toRemove = [] as ArrayList
for (def file : files){
echo """
Found: ${file.name} with path ${file.path}
@ -127,10 +128,10 @@ pipeline {
deploy(record.get(0), record.get(1), record.get(2));
}
}
}
clean("${file.path}");
}
toRemove.add("${file.path}")
}
clean(toRemove)
}
@ -309,14 +310,17 @@ def cleanup(def DEPLOY_FILE, def BACKUP_FILE){
}
//clean and update the local deploy file
def clean(def file){
def clean(def files){
sh '''
echo "cleaning $file";
if [ -f $file ]; then
rm $file;
else
echo "file not exist"
fi
echo "parsing $files";
for file in `ls $dirPath`; do
echo "cleaning $file";
if [ -f $file ]; then
rm $file;
else
echo "file not exist"
fi
done
'''
}