add some print

This commit is contained in:
Roberto Cirillo 2022-10-13 10:24:42 +02:00
parent 6ed0bbb978
commit f494d5dbc3
1 changed files with 54 additions and 24 deletions

78
Jenkinsfile vendored
View File

@ -78,6 +78,8 @@ pipeline {
RELEASE_JOB='gCubeBuilder'
//URL to the YAML file. Used alternatively to RELEASE_JOB
RELEASE_URL= "${params.RELEASE_URL}"
// username of ReleaseManager
RELEASE_MANAGER_USER='roberto.cirillo'
}
parameters {
@ -170,7 +172,8 @@ pipeline {
echo "${TRIGGER_JOB},${TRIGGER_VERSION},${TRIGGER_HOST}" >> ${DEPLOY_FILE}
fi
'''
// the following catch give always an error in order to return a feedback UNSTABLE to the final user since the deploy is still not performed
// the following catch give always an error in order to return a feedback UNSTABLE to the final user since the deploy is still not performed.
// Not sure this is the best approach
catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') {
sh("""
exit 126;
@ -210,7 +213,7 @@ pipeline {
triggeredBy 'BuildUpstreamCause'
triggeredBy 'UpstreamCause'
//added just for testing . To Remove.
triggeredBy cause: "UserIdCause", detail: 'roberto.cirillo'
triggeredBy cause: "UserIdCause", detail: "${RELEASE_MANAGER_USER}"
}
// we should improve this conditional check
equals(actual: "${params.TRIGGER_JOB}", expected: "${RELEASE_JOB}")
@ -219,27 +222,27 @@ pipeline {
script{
if("${DEPLOY_CATEGORY}"){
println("Going to deploy the Release components")
def releaseList = []
// boolean smartgears
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'){
//smartgears = true
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}", 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);
}else { println ("CATEGORIES NOT FOUND ON YAML FILE. SKIP TO NEXT STAGE");}
}
}
}
@ -351,7 +354,7 @@ def parseDeployPendingJobs( def deployFolder){
deployJobs(serviceList.unique())
}
}
//Deploy jobs from an input list with the following elements: serviceName,serviceVersion,targetHost.
//Deploy jobs from an input list with the following elements: serviceName,serviceVersion,targetHost. Create a new stage for any job
def deployJobs(def serviceList){
for (def record : serviceList) {
println("Processing record: "+record)
@ -383,3 +386,30 @@ 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}");
def releaseList = []
String smartgears
def categories=categoryList.split(',')
json.gCube_release.Components.each { group_name, component_list ->
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}")
return
}
releaseList += component_list?.collect {return "$it.name,$it.version" }
println("found ${releaseList}");
}
}
}
}