renamed var json* to yaml*

This commit is contained in:
Roberto Cirillo 2022-10-13 10:53:36 +02:00
parent 526e7e4a0b
commit 628f4c164e
1 changed files with 11 additions and 34 deletions

45
Jenkinsfile vendored
View File

@ -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;
}