diff --git a/Jenkinsfile b/Jenkinsfile index 36e51ec..7021971 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -203,10 +203,12 @@ pipeline { echo '\033[31;1;4mNew upstream deploy ongoing\033[0m' echo "Cron build disabled. Component: ${params.TRIGGER_JOB} - ${params.TRIGGER_VERSION}" ansiColor('xterm') { - catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { - checkup("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}"); - deploy("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}", "${params.TRIGGER_FOO}"); - } + catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') { + checkup("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}"); + } + catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { + deploy("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}", "${params.TRIGGER_FOO}"); + } } } @@ -334,8 +336,10 @@ def deployJobs(def serviceList){ println("Processing deploy: "+service[ 0 ]) catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') { checkup(service[0], service[ 1 ], service[2]); + } + catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { deploy(service[0], service[ 1 ], service[2]); - } + } } } @@ -345,11 +349,23 @@ def deployJobs(def serviceList){ def deploy(String service, String version, String host, String foo){ def now = new Date(); println("Going to deploy the service "+service+" with version: "+version+" on target: "+host+" with argument: "+foo); - def statusCode = sh( script: "cd ${ANSIBLE_ROOT_FOLDER}/CD;./deployService.sh $service $version $host $foo;", returnStdout: true); - sh(""" - echo " last exit code \$?"; - """) - println("Deploy ended with status: "+statusCode); + dir("${ANSIBLE_ROOT_FOLDER}/CD/"){ + sh(""" + git pull; + """) + def statusCode = sh( script: "./deployService.sh $service $version $host $foo;", returnStatus: true); + sh(""" + echo " last exit code \$?"; + """) + println("Deploy statusCode value: "+statusCode); + if (statusCode != 0){ + currentBuild.result = 'FAILURE' + sh(""" + exit $statusCode; + """) + } + } + } @@ -422,9 +438,21 @@ def deployReleaseJobs(def serviceList, String smartgears, boolean isPortlet){ def deployReleaseJob(String service, String version, String smartgears){ def now = new Date(); println("Going to deploy "+service+" "+version+" on preproduction "); - def statusCode = sh( script: "cd ${ANSIBLE_ROOT_FOLDER}/CD;git pull;./deployPreprodService.sh $service $version $smartgears ;", returnStdout: true); - sh(""" - echo " last exit code \$?"; - """) - println("Deploy ended with status: "+statusCode); + dir("${ANSIBLE_ROOT_FOLDER}/CD/"){ + sh(""" + git pull; + """) + def statusCode = sh( script: "./deployPreprodService.sh $service $version $smartgears ;", returnStatus: true); + sh(""" + echo " last exit code \$?"; + """) + println("Deploy ended with status: "+statusCode); + if (statusCode != 0){ + currentBuild.result = 'FAILURE' + sh(""" + exit $statusCode; + """) + } + } + }