fixing parsing function

This commit is contained in:
Roberto Cirillo 2022-04-26 17:05:30 +02:00
parent 96c3e00187
commit 408ae11f44
1 changed files with 30 additions and 15 deletions

43
Jenkinsfile vendored
View File

@ -16,15 +16,10 @@ if (params.deployFile) {
println "Using custom deploy file"
deployList = params.deployFile
} else {
String reportURL = "https://code-repo.d4science.org/gCubeCI/gCubeReleases/raw/branch/master/closed/5.5.0/build_commits.1069.csv"
println "Pulling the report from Git at ${reportURL}"
//load the report from the URL
text = reportURL.toURL().getText()}
// parse the report and extract the data
def components = parseDeployComponent(deployList)
assert 0 < components.size(): "No component found"
for (component in components) {
println "$component"
println "Using local deploy file"
//load the report from local
deployList = agent_root_folder+'/'+agent_deploy_filename;
println "Load from local file ${deployList}"
}
pipeline {
@ -68,9 +63,11 @@ pipeline {
echo 'Components to deploy:'
cat "${DEPLOY_FILE}"
script {
def length="wc -l ${DEPLOY_FILE}"
for (int i = 0; i < length ; ++i) {
echo "Component $i+1: " < "${DEPLOY_FILE}"
// parse the report and extract the data
def components = parseDeployComponent(deployList)
assert 0 < components.size(): "No component found"
for (component in components) {
println "$component"
}
}
}
@ -144,9 +141,27 @@ pipeline {
//a non CPS method is necessary for the usage of splitEachLine()
@NonCPS
def parseDeployComponent(def text) {
def parseDeployComponent(def deployList) {
println "Going to parsing file ${deployList}"
def components = []
"${text}".splitEachLine(',') { columns ->
"${deployList}".splitEachLine(',') { columns ->
if (columns[0].startsWith('#') || columns[0].startsWith('Component'))
return
components.add([
name : columns[0],
version : columns[1]
]
)
}
return components
}
//a non CPS method is necessary for the usage of splitEachLine()
@NonCPS
def oldparseDeployComponentOld(def deployList) {
println "Going to parsing file ${deployList}"
def components = []
"${deployList}".splitEachLine(',') { columns ->
if (columns[0].startsWith('#') || columns[0].startsWith('GroupID'))
return
components.add([