enable check on special yaml category distribution. restored

IS_SCHEDULED_TEST var
This commit is contained in:
Roberto Cirillo 2022-10-12 10:46:02 +02:00
parent de1e8cfd01
commit 71d9b17425
1 changed files with 15 additions and 12 deletions

27
Jenkinsfile vendored
View File

@ -120,7 +120,7 @@ pipeline {
anyOf{ anyOf{
allOf{ allOf{
triggeredBy 'TimerTrigger' triggeredBy 'TimerTrigger'
environment name: 'IS_SCHEDULED', value: 'True' environment name: 'IS_SCHEDULED_TEST', value: 'True'
} }
} }
} }
@ -140,7 +140,7 @@ pipeline {
anyOf{ anyOf{
allOf{ allOf{
triggeredBy 'TimerTrigger' triggeredBy 'TimerTrigger'
environment name: 'IS_SCHEDULED', value: 'False' environment name: 'IS_SCHEDULED_TEST', value: 'False'
} }
} }
@ -152,7 +152,7 @@ pipeline {
} }
stage('New pending deploy ') { stage('New pending deploy ') {
when{ when{
environment name: 'IS_SCHEDULED', value: 'True' environment name: 'IS_SCHEDULED_TEST', value: 'True'
anyOf{ anyOf{
triggeredBy 'BuildUpstreamCause' triggeredBy 'BuildUpstreamCause'
triggeredBy 'UpstreamCause' triggeredBy 'UpstreamCause'
@ -180,7 +180,7 @@ pipeline {
} }
stage('Deploy from job ') { stage('Deploy from job ') {
when{ when{
environment name: 'IS_SCHEDULED', value: 'False'; environment name: 'IS_SCHEDULED_TEST', value: 'False';
expression { expression {
env.TRIGGER_CD.toBoolean() env.TRIGGER_CD.toBoolean()
} }
@ -220,16 +220,19 @@ pipeline {
if("${DEPLOY_CATEGORY}"){ if("${DEPLOY_CATEGORY}"){
println("Going to deploy the Release components") println("Going to deploy the Release components")
def releaseList = [] def releaseList = []
def 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}" == "${DEPLOY_CATEGORY}"){ if("${group_name}" == "$category"){
smartgears = (category == 'Distribution') ? $it.version : ''
def location = (user.city == null) ? user.state : user.city
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); deployReleaseJobs(releaseList, smartgears);
} }
} }
} }
@ -237,7 +240,7 @@ pipeline {
stage('Deploy manually ') { stage('Deploy manually ') {
when{ when{
allOf{ allOf{
environment name: 'IS_SCHEDULED', value: 'False'; environment name: 'IS_SCHEDULED_TEST', value: 'False';
triggeredBy 'UserIdCause' triggeredBy 'UserIdCause'
} }
} }
@ -301,10 +304,10 @@ def checkup(String service, String version, String host){
} }
//launch ansible deploy //launch ansible deploy
def deployRelease(String service, String version){ def deployRelease(String service, String version, String smartgears){
def now = new Date(); def now = new Date();
println("Going to deploy the service "+service+" with version: "+version+" on preproduction "); println("Going to deploy the service "+service+" with version: "+version+" on preproduction ");
def statusCode = sh( script: "cd $ANSIBLE_ROOT_FOLDER;git pull;./deployPreprodService.sh $service $version ;", returnStdout: true); def statusCode = sh( script: "cd $ANSIBLE_ROOT_FOLDER;git pull;./deployPreprodService.sh $service $version $smartgears ;", returnStdout: true);
sh(""" sh("""
echo " last exit code \$?"; echo " last exit code \$?";
""") """)
@ -357,7 +360,7 @@ def deployJobs(def serviceList){
} }
//Deploy only release components. All the component are passed as: componentName,componentVersion //Deploy only release components. All the component are passed as: componentName,componentVersion
def deployReleaseJobs(def serviceList){ def deployReleaseJobs(def serviceList, def smartgears){
for (def record : serviceList) { for (def record : serviceList) {
println("Processing record: "+record) println("Processing record: "+record)
service=record.split(","); service=record.split(",");
@ -365,7 +368,7 @@ def deployReleaseJobs(def serviceList){
println("Processing RELEASE deploy: service "+service[ 0 ]+" with version "+service[ 1 ]) println("Processing RELEASE deploy: service "+service[ 0 ]+" with version "+service[ 1 ])
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
checkupRelease(service[0], service[ 1 ]); checkupRelease(service[0], service[ 1 ]);
deployRelease(service[0], service[ 1 ]); deployRelease(service[0], service[ 1 ], smartgears);
} }
} }
} }