diff --git a/Jenkinsfile b/Jenkinsfile index 8612fe5..c8b2cd5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -92,7 +92,7 @@ pipeline { steps { sh ''' echo "Cron build enabled. New deploy of ${TRIGGER_JOB} - ${TRIGGER_VERSION} appended to the deploy file" - echo "${TRIGGER_JOB} , ${TRIGGER_VERSION}" >> ${DEPLOY_FILE} + echo "${TRIGGER_JOB},${TRIGGER_VERSION}" >> ${DEPLOY_FILE} ''' } } @@ -137,25 +137,8 @@ pipeline { } } -//a non CPS method is necessary for the usage of splitEachLine() -@NonCPS -def parseDeployComponent(def deployList) { - println "Going to parsing file ${deployList}" - def content = readCSV file : "${deployList}" - println "JOB REPORT CONTENT: ${content}" - def components = [] - content.splitEachLine(/,/) { columns -> - if (columns[0].startsWith('#') || columns[0].startsWith('Component')) - return - components.add([ - name : columns[0], - version : columns[1] - ] - ) - } - return components -} +//parse a csv file formatted in this way: ComponentName,ComponentVersion def parseCSVList(def deployList) { def components = [] if (fileExists("${deployList}")) { @@ -167,16 +150,19 @@ def parseCSVList(def deployList) { version : fields[1] ] ) - // for(String item: fields) { - // println item - // println ' you are parsing line : ' + count - // } - - } + } } else { echo ' File Not found. Failing.' } return components } +//Alternative way to append a text in a small file (not used) +def appendToFile(String fileName, String line) { + def current = "" + if (fileExists(fileName)) { + current = readFile fileName + } + writeFile file: fileName, text: current + "\n" + line +}