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' RELEASE_JOB='gCubeBuilder'
//URL to the YAML file. Used alternatively to RELEASE_JOB //URL to the YAML file. Used alternatively to RELEASE_JOB
RELEASE_URL= "${params.RELEASE_URL}" RELEASE_URL= "${params.RELEASE_URL}"
// username of ReleaseManager
RELEASE_MANAGER_USER='roberto.cirillo'
} }
parameters { parameters {
@ -170,7 +172,8 @@ pipeline {
echo "${TRIGGER_JOB},${TRIGGER_VERSION},${TRIGGER_HOST}" >> ${DEPLOY_FILE} echo "${TRIGGER_JOB},${TRIGGER_VERSION},${TRIGGER_HOST}" >> ${DEPLOY_FILE}
fi 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') { catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') {
sh(""" sh("""
exit 126; exit 126;
@ -210,7 +213,7 @@ pipeline {
triggeredBy 'BuildUpstreamCause' triggeredBy 'BuildUpstreamCause'
triggeredBy 'UpstreamCause' triggeredBy 'UpstreamCause'
//added just for testing . To Remove. //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 // we should improve this conditional check
equals(actual: "${params.TRIGGER_JOB}", expected: "${RELEASE_JOB}") equals(actual: "${params.TRIGGER_JOB}", expected: "${RELEASE_JOB}")
@ -219,27 +222,27 @@ pipeline {
script{ script{
if("${DEPLOY_CATEGORY}"){ if("${DEPLOY_CATEGORY}"){
println("Going to deploy the Release components") println("Going to deploy the Release components")
def releaseList = [] deployRelease("${DEPLOY_CATEGORY}", jsonConfig);
// boolean smartgears // def releaseList = []
String smartgears // String smartgears
def categories="${DEPLOY_CATEGORY}".split(',') // def categories="${DEPLOY_CATEGORY}".split(',')
jsonConfig.gCube_release.Components.each { group_name, component_list -> // jsonConfig.gCube_release.Components.each { group_name, component_list ->
for ( def category : categories){ // for ( def category : categories){
if("${group_name}" == "$category"){ // if("${group_name}" == "$category"){
if (category == 'Distribution'){ // if (category == 'Distribution'){
//smartgears = true // //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"; }} // def sg= component_list?.collect{ if ("$it.name" == 'smartgears-distribution'){ return "$it.version"; }}
smartgears=(sg !=null ) ? sg[0] : null // smartgears=(sg !=null ) ? sg[0] : null
println("smartgears version is ${smartgears}") // println("smartgears version is ${smartgears}")
return // return
} // }
releaseList += component_list?.collect {return "$it.name,$it.version" } // releaseList += component_list?.collect {return "$it.name,$it.version" }
println("found ${releaseList}"); // println("found ${releaseList}");
} // }
} // }
} // }
deployReleaseJobs(releaseList, smartgears); // 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()) 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){ def deployJobs(def serviceList){
for (def record : serviceList) { for (def record : serviceList) {
println("Processing record: "+record) 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}");
}
}
}
}