From 628f4c164eea3d1183006fc832fe93cc2d711018 Mon Sep 17 00:00:00 2001 From: "roberto.cirillo" Date: Thu, 13 Oct 2022 10:53:36 +0200 Subject: [PATCH] renamed var json* to yaml* --- Jenkinsfile | 45 +++++++++++---------------------------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 91eb3fa..345a064 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,7 +11,7 @@ import org.yaml.snakeyaml.Yaml def agent_root_folder = '/var/lib/jenkins' def verbose = true -def jsonConfig +def yamlConfig def text if ("${params.gCube_release_version}" || "${params.RELEASE_URL}"){ String releaseURL=''; @@ -24,13 +24,13 @@ if ("${params.gCube_release_version}" || "${params.RELEASE_URL}"){ //load the release file text = releaseURL.toURL().getText() //parsing - jsonConfig = new Yaml().load(text) + yamlConfig = new Yaml().load(text) if (verbose) - println jsonConfig.inspect() - echo "Building gCube v. ${jsonConfig.gCube_release.Version}" + println yamlConfig.inspect() + echo "Building gCube v. ${yamlConfig.gCube_release.Version}" if (verbose) { echo "Found components:" - jsonConfig.gCube_release.Components.each { println it.key } + yamlConfig.gCube_release.Components.each { println it.key } } } @@ -222,26 +222,7 @@ pipeline { script{ if("${DEPLOY_CATEGORY}"){ println("Going to deploy the Release components") - deployRelease("${DEPLOY_CATEGORY}", jsonConfig); -// def releaseList = [] -// String smartgears -// def categories="${DEPLOY_CATEGORY}".split(',') -// jsonConfig.gCube_release.Components.each { group_name, component_list -> -// for ( def category : categories){ -// if("${group_name}" == "$category"){ -// if (category == 'Distribution'){ -// //searching smartgears-distribution version in Distribution component of defined inside the yaml file -// def sg= component_list?.collect{ if ("$it.name" == 'smartgears-distribution'){ return "$it.version"; }} -// smartgears=(sg !=null ) ? sg[0] : null -// println("smartgears version is ${smartgears}") -// return -// } -// releaseList += component_list?.collect {return "$it.name,$it.version" } -// println("found ${releaseList}"); -// } -// } -// } -// deployReleaseJobs(releaseList, smartgears); + deployRelease("${DEPLOY_CATEGORY}", yamlConfig); }else { println ("CATEGORIES NOT FOUND ON YAML FILE. SKIP TO NEXT STAGE");} } } @@ -386,27 +367,23 @@ def deployReleaseJobs(def serviceList, String smartgears){ } } } -// collects all the components belonging to categoryList, in the json file and deploy them -def deployRelease(def categoryList, def json){ - println("Searching component in ${categoryList}"); +// collects all the components defined inside one or more yaml categories matching categoryList +def deployRelease(def categoryList, def yaml){ + if (verbose) println("Searching component in ${categoryList}"); def releaseList = [] String smartgears def categories=categoryList.split(',') - json.gCube_release.Components.each { group_name, component_list -> + yaml.gCube_release.Components.each { group_name, component_list -> if (categories.contains(group_name)){ - println("found category "+group_name+" it is contained in categories to search: "+categories); + if (verbose) println("found category "+group_name+" it is contained in categories to search: "+categories); for ( def category : categories){ - println ("processing category: "+category) if("${group_name}" == "$category"){ if (category == 'Distribution'){ //searching smartgears-distribution version in Distribution component of defined inside the yaml file def sg= component_list?.collect{ if ("$it.name" == 'smartgears-distribution'){ return "$it.version"; }} smartgears=(sg !=null ) ? sg[0] : null - println("smartgears version is ${smartgears}") }else{ releaseList += component_list?.collect {return "$it.name,$it.version" } - println("found ${releaseList}"); - } return; }