add empty folder check

This commit is contained in:
Roberto Cirillo 2022-09-08 14:40:49 +02:00
parent 9ac38b137e
commit c87343479e
1 changed files with 25 additions and 23 deletions

48
Jenkinsfile vendored
View File

@ -291,27 +291,29 @@ def cleanup(def DEPLOY_FILE, def BACKUP_FILE){
//experimental test
def getComponentsFromCSVDir(def dirPath){
File folder = new File(dirPath)
println "folder ready "
folder.eachFileRecurse FileType.FILES, { file ->
// check it if the file ends with a .csv extension
if (file.name.endsWith(".csv")) {
println "Processing file "
readFile(file).split('\n').each { line, count->
if (line.startsWith('#'))
return
def fields = line.split(',')
components.add([
name : fields[0],
version : fields[1],
host : fields[2]
]
)
}
}
println "removing current deploy file"
// remove the file here if possible
// file.delete();
}
return components
File folder = new File(dirPath)
println "folder ready "
if (folder){
folder.eachFileRecurse FileType.FILES, { file ->
// check it if the file ends with a .csv extension
if (file.name.endsWith(".csv")) {
println "Processing file "
readFile(file).split('\n').each { line, count->
if (line.startsWith('#'))
return
def fields = line.split(',')
components.add([
name : fields[0],
version : fields[1],
host : fields[2]
]
)
}
}
println "removing current deploy file: "+file.name
// remove the file here if possible
// file.delete();
}
}
return components
}