From 11353d91df238c5ac33681c1b3673c64ed8fb822 Mon Sep 17 00:00:00 2001 From: Roberto Cirillo Date: Tue, 26 Apr 2022 15:16:49 +0200 Subject: [PATCH] add function for managing the deploy file --- Jenkinsfile | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 35aaed4..9d3879f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,7 +9,23 @@ // related jenkins job: https://jenkins.d4science.org/job/gCubeDeployer/ 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 { 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 +}