add function for managing the deploy file

This commit is contained in:
Roberto Cirillo 2022-04-26 15:16:49 +02:00
parent 52d802c6b3
commit 11353d91df
1 changed files with 31 additions and 0 deletions

31
Jenkinsfile vendored
View File

@ -9,7 +9,23 @@
// related jenkins job: https://jenkins.d4science.org/job/gCubeDeployer/ // related jenkins job: https://jenkins.d4science.org/job/gCubeDeployer/
def agent_root_folder = '/var/lib/jenkins/.m2' def agent_root_folder = '/var/lib/jenkins/.m2'
def agent_deploy_filename = 'deploy.csv'
def deployList
if (params.deployFile) {
println "Using custom deploy file"
deployList = params.deployFile
} else {
println "Using local deploy file"
//load the report from the URL
deployList = agent_root_folder+'/'+agent_deploy_filename;
}
// parse the report and extract the data
def components = parseDeployComponent(deployList)
assert 0 < components.size(): "No component found"
for (component in components) {
println "$component"
}
pipeline { pipeline {
agent { agent {
@ -126,3 +142,18 @@ pipeline {
} }
} }
//a non CPS method is necessary for the usage of splitEachLine()
@NonCPS
def parseDeployComponent(def deployList) {
def components = []
"${deployList}".splitEachLine(',') { columns ->
if (columns[0].startsWith('#') || columns[0].startsWith('Components'))
return
components.add([
name : columns[1],
version : columns[2],
]
)
}
return components
}