From eec8436621f7f064ffb0f488e7e1340e8d100ca8 Mon Sep 17 00:00:00 2001 From: "roberto.cirillo" Date: Fri, 9 Sep 2022 14:35:25 +0200 Subject: [PATCH] new test method for parsing the file --- Jenkinsfile | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 96bb4fc..64f1295 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -99,7 +99,7 @@ pipeline { // parse the report and extract the data // def components = getComponentsFromCSV(deployList) println "Going to check the deploy file in ${DEPLOY_FILE_ROOT_FOLDER}" - def components =getComponentsFromCSVDir("${DEPLOY_FILE_ROOT_FOLDER}") + def components =getComponentsFromCSVDir2("${DEPLOY_FILE_ROOT_FOLDER}") if (components.size() > 0) { def componentSet=components.toSet(); for (component in componentSet) { @@ -319,4 +319,35 @@ def getComponentsFromCSVDir(def dirPath){ } } return components -} \ No newline at end of file +} + +def getComponentsFromCSVDir2(def dirPath){ + File folder = new File(dirPath) + println ("folder ready "); + if (folder){ + println (" processing folder "+folder); + folder.eachFileRecurse( FileType.FILES) { + if (it.name.endsWith(".csv")) { + println ("Processing file "+it); + readFile(it).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: "+it.name); + // remove the file here if possible + // file.delete(); + } + } + return components +} + + +