From 1c77e7bd45168f128e506db44fe0dc4e81506dc2 Mon Sep 17 00:00:00 2001 From: hahn <axel.hahn@iml.unibe.ch> Date: Tue, 3 Aug 2021 17:43:52 +0200 Subject: [PATCH] task #4637 - awx: put echo with error and curl into single command --- public_html/deployment/plugins/rollout/awx/rollout_awx.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/public_html/deployment/plugins/rollout/awx/rollout_awx.php b/public_html/deployment/plugins/rollout/awx/rollout_awx.php index 800a2531..276cca0a 100644 --- a/public_html/deployment/plugins/rollout/awx/rollout_awx.php +++ b/public_html/deployment/plugins/rollout/awx/rollout_awx.php @@ -147,16 +147,17 @@ class rollout_awx extends rollout_base { $aConfig=$this->getConfig($sPhase); // ----- Checks: + $sCmdChecks=''; if($aConfig['extravars']){ $aTmp=json_decode($aConfig['extravars']); if (!$aTmp || !count($aTmp) ){ - $aReturn[]='echo "ERROR: Value in extravars has wrong Syntax - this is no JSON: '.$aConfig['extravars'].'"'; + $sCmdChecks.='echo "ERROR: Value in extravars has wrong Syntax - this is no JSON: '.$aConfig['extravars'].'"; exit 1; '; } $aConfig['extravars']=json_encode($aTmp); } if(!(int)$aConfig['inventory']){ - $aReturn[]='echo "ERROR: no inventory was given."; exit 1'; + $sCmdChecks.='echo "ERROR: no inventory was given."; exit 1; '; } // ----- Send variables having values only @@ -168,7 +169,7 @@ class rollout_awx extends rollout_base { } $sAuth=($aConfig['user'] ? '--user '.$aConfig['user'].':'.$aConfig['password'] : ''); - $aReturn[]="curl -f -k -H 'Content-Type: application/json' -XPOST -d '". json_encode($aBodyvars, JSON_PRETTY_PRINT)."' $sAuth ".$aConfig['url']."/job_templates/".$aConfig['jobtemplate']."/launch/"; + $aReturn[]=$sCmdChecks . "curl -f -k -H 'Content-Type: application/json' -XPOST -d '". json_encode($aBodyvars, JSON_PRETTY_PRINT)."' $sAuth ".$aConfig['url']."/job_templates/".$aConfig['jobtemplate']."/launch/"; return $aReturn; } -- GitLab