From c1dcadbe6d8cb54df810965b2e3525e32ff17b47 Mon Sep 17 00:00:00 2001
From: hahn <axel.hahn@iml.unibe.ch>
Date: Tue, 3 Aug 2021 18:12:49 +0200
Subject: [PATCH] task #4637 - deploy shows error in red if sonmething failed;
 debug output for plugins was reoved.

---
 config/lang/de.json                           |  3 ++-
 config/lang/en.json                           |  1 +
 .../deployment/classes/project.class.php      | 21 +++++++++++--------
 3 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/config/lang/de.json b/config/lang/de.json
index b3dd2dac..6776db8f 100644
--- a/config/lang/de.json
+++ b/config/lang/de.json
@@ -131,7 +131,8 @@
     "class-project-info-deploy-skip-sync": "SKIP: Synchronisationstyp &quot;%s&quot; wird (noch) nicht unterst&uuml;tzt.",
     "class-project-info-deploy-start-by-method": "Starte Installation auf Zielhosts",
     "class-project-info-deploy-start-by-method-skip": "SKIP: es gibt nichts zu tun. Wurde keine Installationsart und/ oder kein Ziel Host definiert.",    
-    "class-project-info-deploy-successful": "Das Deployment wurde erfolgreich abgeschlossen.",
+    "class-project-info-deploy-successful": "Das Deployment der Phase %s wurde erfolgreich abgeschlossen.",
+    "class-project-info-deploy-failed": "Das Deployment der Phase %s enth&auml;lt Fehler.",
     "class-project-info-accept-overview": "Info: in der Phase &quot;%s&quot; ist installiert:",
     "class-project-info-accept-version-and-next-phase": "Die aktuelle Version [%s] wird nun in die Queue der Phase [%s] gestellt.",
     "class-project-info-setup-phaseinfos": "Aktiviere die Phasen des Projektes und gib die URLs der jeweiligen Applikationen an.<br>Der Sysadmin muss zudem die einzelnen Hosts in Puppet konfigurieren - bitte neu zuverwendende Server mit ihm abstimmen.",
diff --git a/config/lang/en.json b/config/lang/en.json
index 50786dcd..fce023ff 100644
--- a/config/lang/en.json
+++ b/config/lang/en.json
@@ -133,6 +133,7 @@
     "class-project-info-deploy-start-by-method": "Starting installation to target hosts",
     "class-project-info-deploy-start-by-method-skip": "SKIP: nothing to do. No method an/ or target host were defined.",
     "class-project-info-deploy-successful": "The deployment was finished successfully.",
+    "class-project-info-deploy-failed": "The deployment failed.",
     "class-project-info-accept-overview": "Info: in the phase &quot;%s&quot; is installed:",
     "class-project-info-accept-version-and-next-phase": "The current version [%s] will be put to the queue of phase [%s].",
     "class-project-info-setup-phaseinfos": "Activate the needed phases for your project. Enter the urls of each phase.<br>Fore new hosts: contact the system administrator - he must configure the hosts before the project can be installed there.",
diff --git a/public_html/deployment/classes/project.class.php b/public_html/deployment/classes/project.class.php
index 37d30111..954fade3 100644
--- a/public_html/deployment/classes/project.class.php
+++ b/public_html/deployment/classes/project.class.php
@@ -2191,12 +2191,7 @@ class project extends base {
             $sReturn.=t("class-project-info-deploy-start-by-method-skip") . "<br>";
         } else {
             
-            $sReturn.='<p>'
-                    . 'Plugin: '.$this->oRolloutPlugin->getId().'<br>'
-                    . '</p>'
-                    . '<pre>Config for phase '.$sPhase.' = '.print_r($this->oRolloutPlugin->getConfig($sPhase), 1).'</pre>'
-                    . '<pre>Commands = '.print_r($this->oRolloutPlugin->getDeployCommands($sPhase), 1).'</pre>'
-                    ;
+            $sReturn.='<p>' . 'Plugin: '.$this->oRolloutPlugin->getId().'</p>';
 
             foreach($this->oRolloutPlugin->getDeployCommands($sPhase) as $sCmd){
                 $sReturn.=$this->_execAndSend("$sCmd");
@@ -2234,10 +2229,18 @@ class project extends base {
         $this->_TempFill($sReturn, $aActionList);
 
         $sReturn.="<br>";
-        $sReturn.=$this->_oHtml->getBox("success", t("class-project-info-deploy-successful"));
         
-        $this->_sendMessage(t("class-project-info-deploy-successful")."\nphase: ${sPhase}\n");
-        $this->_logaction(t('finished') . " deploy($sPhase, $bIgnoreDeploytimes) " . t("class-project-info-deploy-successful"), __FUNCTION__, "success");
+        if (!$this->_iRcAll == 0) {
+            $sWarnlevel='error';
+            $sMessage = sprintf(t('class-project-info-deploy-failed'), $sPhase);
+        } else {
+            $sWarnlevel='success';
+            $sMessage=sprintf(t("class-project-info-deploy-successful"), $sPhase);
+        }
+        $sReturn.=$this->_oHtml->getBox($sWarnlevel, $sMessage);
+        $this->_sendMessage($sMessage);
+        $this->_logaction(t('finished') . " deploy($sPhase, $bIgnoreDeploytimes) " . $sMessage, __FUNCTION__, $sWarnlevel);
+        
         $this->_TempDelete();
         return $sReturn;
     }
-- 
GitLab