From dccaa780fca1e16216153066aefdf290056fe9fe Mon Sep 17 00:00:00 2001 From: Christopher Fenner Date: Fri, 12 Apr 2019 09:07:53 +0200 Subject: [PATCH] cloudFoundryDeploy: return proper error message on deploy error (#651) * return proper error message on deploy error * fix typo * provide meaningful error messages * Update cloudFoundryDeploy.groovy * Update cloudFoundryDeploy.groovy * Update neoDeploy.groovy * Update neoDeploy.groovy --- vars/cloudFoundryDeploy.groovy | 10 ++++++++-- vars/neoDeploy.groovy | 15 ++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/vars/cloudFoundryDeploy.groovy b/vars/cloudFoundryDeploy.groovy index 5c2aad0b8..5128f6002 100644 --- a/vars/cloudFoundryDeploy.groovy +++ b/vars/cloudFoundryDeploy.groovy @@ -163,7 +163,7 @@ def deployCfNative (config) { } } - sh """#!/bin/bash + def returnCode = sh returnStatus: true, script: """#!/bin/bash set +x set -e export HOME=${config.dockerWorkspace} @@ -171,6 +171,9 @@ def deployCfNative (config) { cf plugins cf ${deployCommand} ${config.cloudFoundry.appName ?: ''} ${blueGreenDeployOptions} -f '${config.cloudFoundry.manifest}' ${config.smokeTest} """ + if(returnCode != 0){ + error "[ERROR][${STEP_NAME}] The execution of the deploy command failed, see the log for details." + } stopOldAppIfRunning(config) sh "cf logout" } @@ -228,7 +231,7 @@ def deployMta (config) { usernameVariable: 'username' )]) { echo "[${STEP_NAME}] Deploying MTA (${config.mtaPath}) with following parameters: ${config.mtaExtensionDescriptor} ${config.mtaDeployParameters}" - sh """#!/bin/bash + def returnCode = sh returnStatus: true, script: """#!/bin/bash export HOME=${config.dockerWorkspace} set +x set -e @@ -236,6 +239,9 @@ def deployMta (config) { cf login -u ${username} -p '${password}' -a ${config.cloudFoundry.apiEndpoint} -o \"${config.cloudFoundry.org}\" -s \"${config.cloudFoundry.space}\" cf plugins cf ${deployCommand} ${config.mtaPath} ${config.mtaDeployParameters} ${config.mtaExtensionDescriptor}""" + if(returnCode != 0){ + error "[ERROR][${STEP_NAME}] The execution of the deploy command failed, see the log for details." + } sh "cf logout" } } diff --git a/vars/neoDeploy.groovy b/vars/neoDeploy.groovy index 19f4ddba4..c136fb6ab 100644 --- a/vars/neoDeploy.groovy +++ b/vars/neoDeploy.groovy @@ -128,15 +128,24 @@ private deploy(script, utils, Map configuration, NeoCommandHelper neoCommandHelp echo "Link to the application dashboard: ${neoCommandHelper.cloudCockpitLink()}" if (warAction == WarAction.ROLLING_UPDATE) { - sh neoCommandHelper.rollingUpdateCommand() + def returnCodeRollingUpdate = sh returnStatus: true, script: neoCommandHelper.rollingUpdateCommand() + if(returnCodeRollingUpdate != 0){ + error "[ERROR][${STEP_NAME}] The execution of the deploy command failed, see the log for details." + } } else { - sh neoCommandHelper.deployCommand() + def returnCodeDeploy = sh returnStatus: true, script: neoCommandHelper.deployCommand() + if(returnCodeDeploy != 0){ + error "[ERROR][${STEP_NAME}] The execution of the deploy command failed, see the log for details." + } sh neoCommandHelper.restartCommand() } } else if (deployMode == DeployMode.MTA) { - sh neoCommandHelper.deployMta() + def returnCodeMTA = sh returnStatus: true, script: neoCommandHelper.deployMta() + if(returnCodeMTA != 0){ + error "[ERROR][${STEP_NAME}] The execution of the deploy command failed, see the log for details." + } } } }