diff --git a/config/lang/de.json b/config/lang/de.json
index 799346e12ece729bf23d97e71e6ff87d0bb8d766..e3711a1c20f58a56085978d717eb002ec94c3385 100644
--- a/config/lang/de.json
+++ b/config/lang/de.json
@@ -76,6 +76,7 @@
     "class-project-error-build-dir-was-not-created": "Das Verzeichnis %s wurde nicht angelegt.",
     "class-project-error-build-type-not-supported": "Repository Typ %s wird nicht unterstützt.",
     "class-project-error-build-docroot-not-found": "Es gibt kein Unterverzeichnis "public_html" oder "public" im Arbeitsverzeichnis.",
+    "class-project-error-build-packaging-failed": "Build schlug beim Erstellen der Pakete fehl.",
     "class-project-error-command-failed": "Eines der Kommandos ist fehlgeschlagen (s. Fehlermeldung in der Ausgabe).<br>Frage ggf. den Administrator. Das Arbeitsverzeichnis wird f&uumlr eine Analyse nicht gel&ouml;scht.",
     "class-project-error-getPhaseInfos-package-not-found": "Die Paket-Datei (.tgz) wurde nicht gefunden: %s",
     "class-project-error-getPhaseInfos-requires-phase": "Die Methode getPhaseInfos erfordert die Angabe eine Phase.",
diff --git a/config/lang/en.json b/config/lang/en.json
index c8b03b0e2a01e81594abcbb9620fbb8de2112ec3..e1a65046f3c03f074905741740030eed5dce591e 100644
--- a/config/lang/en.json
+++ b/config/lang/en.json
@@ -75,6 +75,7 @@
     "class-project-error-build-dir-was-not-created": "The directory %s was not created.",
     "class-project-error-build-type-not-supported": "Repository type %s is not supported.",
     "class-project-error-build-docroot-not-found": "There is no subdirectory &quot;public_html&quot; or &quot;public&quot; in the working directory.",
+    "class-project-error-build-packaging-failed": "Build failed while creating the packages.",
     "class-project-error-command-failed": "The execution of a command failed (see error message in the output below).<br>Ask your admin. The working directory was NOT deleted that you can analyze the problem.",
     "class-project-error-getPhaseInfos-package-not-found": "The package file (.tgz) was not found: %s",
     "class-project-error-getPhaseInfos-requires-phase": "The method getPhaseInfos requires the name of a pfase.",
diff --git a/public_html/check-config.php b/public_html/check-config.php
index b3337f9bf380aacf13da049ea6d3f5a7a9cd793f..f73d7ec99c2924cfec24c0c1c5ba68bf005d6d52 100644
--- a/public_html/check-config.php
+++ b/public_html/check-config.php
@@ -177,8 +177,8 @@ if (!isset($aConfig) || !is_array($aConfig)) {
     echo '<h2>Check keys</h2>';
     // check required keys in the config
     foreach (array(
-    'auth',
-     'hooks',
+     'auth',
+     'build',
      'installPackages',
      'lang',
      'phases',
diff --git a/public_html/deployment/classes/project.class.php b/public_html/deployment/classes/project.class.php
index 74f6fabc166f79e85e0306bbb155cbad3e74d117..661f24a406e5254d8a0e9f53c16f6992d619e133 100644
--- a/public_html/deployment/classes/project.class.php
+++ b/public_html/deployment/classes/project.class.php
@@ -608,6 +608,35 @@ class project extends base {
         ksort($this->_aVersions);
         return $this->_aVersions;
     }
+    /**
+     * get an array with all existing build error output files (html)
+     * @return array
+     */
+    public function getBuildErrors($sProject=false) {
+        // --- read all file entries
+        $aReturn = array();
+        if(!$sProject){
+            $sProject=$this->_aPrjConfig["fileprefix"].'_*';
+        }
+        foreach( glob($this->_getBuildDir() . '/' . $sProject . "/_output.html" ) as $sBuildDir){
+            $aReturn[] = basename(dirname($sBuildDir)).'/'.basename($sBuildDir);
+        }
+        return $aReturn;
+    }
+    /**
+     * get an array with all existing build error output files (html)
+     * @return array
+     */
+    public function getBuildErrorContent($sLogfile) {
+        if (!strpos('..', $sLogfile)===false){
+            return false;
+        }
+        $sFilename=$this->_getBuildDir() . '/' . $sLogfile;
+        if(file_exists($sFilename)){
+            return file_get_contents($sFilename);
+        }
+        return false;
+    }
 
     /**
      * get Array of all versions, metainfos, in which phases they are in use 
@@ -1454,14 +1483,20 @@ class project extends base {
     }
 
     /**
-     * delete tempfile for ajax polling
-     * @param type $sTmpFile
+     * delete tempfile for ajax polling; if a directory is given as parameter
+     * the tmp file will be moved there 
+     * @param string  $sTempDir  optional; target dir to copy; default=false (=delete file)
      * @return boolean
      */
-    private function _TempDelete() {
-        if (!$this->_sProcessTempOut)
+    private function _TempDelete($sTempDir=false) {
+        if (!$this->_sProcessTempOut){
             return false;
+        }
         if (file_exists($this->_sProcessTempOut)) {
+            if ($sTempDir && is_dir($sTempDir)){
+                $sKeepOutfile=$sTempDir.'/_output.html';
+                copy($this->_sProcessTempOut, $sKeepOutfile);
+            }
             unlink($this->_sProcessTempOut);
         }
         return file_exists($this->_sProcessTempOut);
@@ -1543,7 +1578,7 @@ class project extends base {
         // --------------------------------------------------
         // create workdir
         // --------------------------------------------------
-        $sTempDir = $this->_getTempDir();
+        $sTempBuildDir = $this->_getTempDir();
         $sFirstLevel = $this->getNextPhase();
         if (!$sFirstLevel) {
             $this->_TempDelete();
@@ -1552,13 +1587,13 @@ class project extends base {
         }
 
         $sReturn.='<h3>' . t('class-project-build-label-create-workdir') . '</h3>';
-        if (!file_exists($sTempDir)) {
-            $sReturn.=$this->_execAndSend("mkdir -p " . $sTempDir);
+        if (!file_exists($sTempBuildDir)) {
+            $sReturn.=$this->_execAndSend("mkdir -p " . $sTempBuildDir);
         }
-        $sReturn.=$this->_execAndSend("ls -ld " . $sTempDir);
-        if (!file_exists($sTempDir)) {
+        $sReturn.=$this->_execAndSend("ls -ld " . $sTempBuildDir);
+        if (!file_exists($sTempBuildDir)) {
             $this->_TempDelete();
-            $sError = sprintf(t('"class-project-error-build-dir-was-not-created"'), $sTempDir);
+            $sError = sprintf(t('"class-project-error-build-dir-was-not-created"'), $sTempBuildDir);
             $this->_logaction($sError, __FUNCTION__, "error");
             return $oHtml->getBox("error", $sError . $sReturn);
         }
@@ -1571,26 +1606,26 @@ class project extends base {
         // --------------------------------------------------
         $sReturn.='<h3>' . t('class-project-build-label-get-sources-from-version-control') . '</h3>';
 
-        $sReturn.='<pre>' . $this->_oVcs->getSources($sTempDir) . '</pre>';
+        $sReturn.='<pre>' . $this->_oVcs->getSources($sTempBuildDir) . '</pre>';
 
-        $aVersion = $this->_oVcs->getRevision($sTempDir);
+        $aVersion = $this->_oVcs->getRevision($sTempBuildDir);
         $sRevision = $aVersion["revision"];
         $sCommitMsg = $aVersion["message"];
         $sCommitMsg = str_replace("\n", "<br>", $sCommitMsg);
         $sCommitMsg = str_replace('"', "&quot;", $sCommitMsg);
         $sReturn.=$oHtml->getBox("info", $sCommitMsg);
 
-        $sReturn.=$this->_execAndSend("ls -lisa $sTempDir");
+        $sReturn.=$this->_execAndSend("ls -lisa $sTempBuildDir");
 
         if (!$this->_iRcAll == 0) {
-            $this->_TempDelete();
-            $sError = sprintf(t('class-project-error-command-failed'), $sTempDir) . $sReturn;
+            $this->_TempDelete($sTempBuildDir);
+            $sError = sprintf(t('class-project-error-command-failed'), $sTempBuildDir) . $sReturn;
             $this->_logaction($sError, __FUNCTION__, "error");
             return $oHtml->getBox("error", $sError);
         }
 
         // --------------------------------------------------
-        foreach (glob($sTempDir . '/hooks/on*') as $filename) {
+        foreach (glob($sTempBuildDir . '/hooks/on*') as $filename) {
             $sReturn.='chmod 755 ' . $filename . '<br>';
             $sReturn.=$this->_execAndSend('chmod 755 ' . $filename);
             $sReturn.=$this->_execAndSend('ls -l ' . $filename);
@@ -1608,20 +1643,21 @@ class project extends base {
         $sSetEnv=''
                 . 'export GIT_SSH="'.$this->_aConfig['appRootDir'].'/shellscripts/gitsshwrapper.sh";'
                 . 'export DIR_SSH_KEYS="'.$this->_aConfig['dataDir'].'/sshkeys";'
-                . 'export DIR_APPROOT="'.$sTempDir.'";'
+                . 'export DIR_APPROOT="'.$sTempBuildDir.'";'
+                . (isset($this->_aConfig['build']['env']) ? $this->_aConfig['build']['env'] : '')
                 ;
         
-        $sHookfile = $this->_aConfig['hooks']['build-postclone'];
+        $sHookfile = $this->_aConfig['build']['hooks']['build-postclone'];
         $sReturn.='<h3>' . t('class-project-build-label-execute-hook-postclone') . ' (' . $sHookfile . ')</h3>';
         
-        if (file_exists($sTempDir . '/' . $sHookfile)) {
+        if (file_exists($sTempBuildDir . '/' . $sHookfile)) {
             // $sReturn.=$this->_execAndSend('chmod 755 ' . $sTempDir . '/hooks/on*');
             // $this->_iRcAll = 0;
-            $sReturn.=$this->_execAndSend('bash --login -c \'' . $sSetEnv.' '.$sTempDir . '/' . $sHookfile . '\'');
+            $sReturn.=$this->_execAndSend('bash --login -c \'' . $sSetEnv.' '.$sTempBuildDir . '/' . $sHookfile . '\'');
             if (!$this->_iRcAll == 0) {
-                $sError = sprintf(t('class-project-error-command-failed'), $sTempDir);
+                $sError = sprintf(t('class-project-error-command-failed'), $sTempBuildDir);
                 $this->_logaction($sError, __FUNCTION__, "error");
-                $this->_TempDelete();
+                $this->_TempDelete($sTempBuildDir);
                 return $oHtml->getBox("error", $sError . $sReturn);
             }
         } else {
@@ -1637,7 +1673,7 @@ class project extends base {
         $sReturn.='<h3>' . t('class-project-build-label-copy-default-structure') . '</h3>';
         if ($this->_getDefaultsDir()) {
             $sReturn.=$this->_execAndSend("find " . $this->_getDefaultsDir() . " | head -15");
-            $sReturn.=$this->_execAndSend("rsync -r " . $this->_getDefaultsDir() . "/* $sTempDir");
+            $sReturn.=$this->_execAndSend("rsync -r " . $this->_getDefaultsDir() . "/* $sTempBuildDir");
             // $sReturn.=$this->_execAndSend("find $sTempDir");
         } else {
             $sReturn.=t('skip') . '<br>';
@@ -1648,15 +1684,15 @@ class project extends base {
         // --------------------------------------------------
         // execute hook
         // --------------------------------------------------
-        $sHookfile = $this->_aConfig['hooks']['build-precompress'];
+        $sHookfile = $this->_aConfig['build']['hooks']['build-precompress'];
         $sReturn.='<h3>' . t('class-project-build-label-execute-hook-precompress') . ' (' . $sHookfile . ')</h3>';
-        if (file_exists($sTempDir . '/' . $sHookfile)) {
+        if (file_exists($sTempBuildDir . '/' . $sHookfile)) {
             // $sReturn.=$this->_execAndSend('chmod 755 ' . $sTempDir . '/hooks/on*');
             // $this->_iRcAll = 0;
-            $sReturn.=$this->_execAndSend('bash --login -c \'' . $sSetEnv.' '.$sTempDir . '/' . $sHookfile . '\'');
+            $sReturn.=$this->_execAndSend('bash --login -c \'' . $sSetEnv.' '.$sTempBuildDir . '/' . $sHookfile . '\'');
             if (!$this->_iRcAll == 0) {
-                $this->_TempDelete();
-                $sError = sprintf(t('class-project-error-command-failed'), $sTempDir) . $sReturn;
+                $this->_TempDelete($sTempBuildDir);
+                $sError = sprintf(t('class-project-error-command-failed'), $sTempBuildDir) . $sReturn;
                 $this->_logaction($sError, __FUNCTION__, "error");
                 return $oHtml->getBox("error", $sError);
             }
@@ -1672,7 +1708,7 @@ class project extends base {
         // --------------------------------------------------
         $sReturn.='<h3>' . t('class-project-build-label-cleanup-project') . '</h3>';
         if ($this->_oVcs) {
-            $this->_oVcs->cleanupWorkdir($sTempDir);
+            $this->_oVcs->cleanupWorkdir($sTempBuildDir);
         }
 
         // $sReturn.=$this->_execAndSend("cd $sTempDir && rm -rf .git");
@@ -1689,27 +1725,31 @@ class project extends base {
         if (array_key_exists('haspublic', $this->_aPrjConfig["build"])
                 && $this->_aPrjConfig["build"]["haspublic"][0]
         ){
-            // $sReturn.='<p>DO check for docroot<p>';
+            $sReturn.='<p>DO check for docroot<p>';
             $sWebroot = false;
-            $sWebroot1 = $sTempDir . '/public_html';
-            $sWebroot2 = $sTempDir . '/public';
+            $sWebroot1 = $sTempBuildDir . '/public_html';
+            $sWebroot2 = $sTempBuildDir . '/public';
+            $sReturn.="<p>1 - $sWebroot1<br>2 - $sWebroot2<p>";
             if (file_exists($sWebroot1)) {
+                $sReturn.="OK 1 - $sWebroot1<br>";
                 $sWebroot = $sWebroot1;
             }
             if (file_exists($sWebroot2)) {
+                $sReturn.="OK 2 - $sWebroot2<br>";
                 $sWebroot = $sWebroot2;
             }
 
+            $sReturn.="webroot = $sWebroot<br>";
             if (!$sWebroot) {
-                $this->_TempDelete();
+                $this->_TempDelete($sTempBuildDir);
                 $sError = t('class-project-error-build-docroot-not-found');
                 $this->_logaction($sError, __FUNCTION__, "error");
                 return $oHtml->getBox("error", $sError . $sReturn . $sError);
             }
         }
         if (!$this->_iRcAll == 0) {
-            $this->_TempDelete();
-            $sError = sprintf(t('class-project-error-command-failed'), $sTempDir) . $sReturn;
+            $this->_TempDelete($sTempBuildDir);
+            $sError = sprintf(t('class-project-error-command-failed'), $sTempBuildDir) . $sReturn;
             $this->_logaction($sError, __FUNCTION__, "error");
             return $oHtml->getBox("error", $sError);
         }
@@ -1718,7 +1758,7 @@ class project extends base {
         $sTs = date("Y-m-d H:i:s");
         $sTs2 = date("Ymd_His");
         $sBranch = ($this->_sBranchname ? $this->_sBranchname : t("defaultbranch"));
-        $sInfoFileWebroot = $sTempDir . '/' . basename($this->_getInfofile($sFirstLevel, "deployed"));
+        $sInfoFileWebroot = $sTempBuildDir . '/' . basename($this->_getInfofile($sFirstLevel, "deployed"));
         $sInfoFileArchiv = $this->_getArchiveDir($sTs2) . '/' . basename($this->_getInfofile($sFirstLevel, "deployed"));
         $sPackageFileArchiv = $this->_getArchiveDir($sTs2) . '/' . basename($this->_getPackagefile($sFirstLevel, "deployed"));
 
@@ -1756,8 +1796,8 @@ class project extends base {
         }
         $sReturn.=$this->_execAndSend("ls -ld " . dirname($sPackageFileArchiv));
         if (!file_exists(dirname($sPackageFileArchiv))) {
-            $this->_TempDelete();
-            $sError = sprintf(t('"class-project-error-build-dir-was-not-created"'), $sTempDir);
+            $this->_TempDelete($sTempBuildDir);
+            $sError = sprintf(t('"class-project-error-build-dir-was-not-created"'), $sTempBuildDir);
             $this->_logaction($sError, __FUNCTION__, "error");
             return $oHtml->getBox("error", $sError . $sReturn);
         }
@@ -1766,7 +1806,7 @@ class project extends base {
 
         // create tgz archive
         $sReturn.=sprintf(t("creating-file"), $sPackageFileArchiv) . "<br>";
-        $sReturn.=$this->_execAndSend("cd $sTempDir && tar -czf $sPackageFileArchiv .");
+        $sReturn.=$this->_execAndSend("cd $sTempBuildDir && tar -czf $sPackageFileArchiv .");
         $this->_TempFill($sReturn, $aActionList);
 
         // write info file (.json)
@@ -1775,9 +1815,9 @@ class project extends base {
         file_put_contents($sInfoFileArchiv, json_encode($aInfos));
 
         // copy template files
-        if (file_exists($sTempDir . '/hooks/templates/')) {
+        if (file_exists($sTempBuildDir . '/hooks/templates/')) {
             $sReturn.=t("class-project-info-build-write-templatefiles-to-archive") . "<br>";
-            $sReturn.=$this->_execAndSend("cp $sTempDir/hooks/templates/* " . $this->_getArchiveDir($sTs2));
+            $sReturn.=$this->_execAndSend("cp $sTempBuildDir/hooks/templates/* " . $this->_getArchiveDir($sTs2));
         } else {
             $sReturn.=t("class-project-info-build-write-templatefiles-to-archive-skipped") . "<br>";
         }
@@ -1786,9 +1826,11 @@ class project extends base {
         $sReturn.="<br>" . t("info") . ":<br>";
         $sReturn.=$this->_execAndSend("ls -l " . $this->_getArchiveDir($sTs2));
 
+        // TEST
+        // $this->_iRcAll=1;
         if (!$this->_iRcAll == 0) {
-            $this->_TempDelete();
-            $sError = t('class-project-error-build-docroot-not-found');
+            $this->_TempDelete($sTempBuildDir);
+            $sError = t('class-project-error-build-packaging-failed');
             $this->_logaction($sError, __FUNCTION__, "error");
             return $oHtml->getBox("error", $sError . $sReturn);
         }
@@ -1796,7 +1838,7 @@ class project extends base {
         $this->_TempFill($sReturn, $aActionList);
 
         $sReturn.='<h3>' . t("class-project-build-label-remove-workdir") . '</h3>';
-        $sReturn.=$this->_execAndSend("rm -rf $sTempDir");
+        $sReturn.=$this->_execAndSend("rm -rf $sTempBuildDir");
         $sReturn.=t("class-project-info-build-remove-oldest-archives");
         $sReturn.='<pre>' . print_r($this->cleanupArchive(), true) . '</pre>';
 
@@ -2919,6 +2961,7 @@ class project extends base {
             return $oHtml->getBox("info", t('class-project-info-no-package'));
         }
 
+        echo "<pre>" . print_r($this->getBuildErrors(), 1) . "</pre>";
         foreach ($this->getActivePhases() as $sPhase) {
             $sRowHead1.='<th class="' . $sPhase . '" colspan="' . (count($this->_aPlaces) + 1) . '">' . $sPhase . '</th>';
             $sRowHead2.='<td></td>' . $this->renderPlacesAsTd($sPhase);
diff --git a/public_html/deployment/inc_functions.php b/public_html/deployment/inc_functions.php
index ec9c8083e5711e77b9eecfd6cf37f324a472c314..e0396d9bf01f60272ffcb6c4f8f8539c19c3bbdc 100644
--- a/public_html/deployment/inc_functions.php
+++ b/public_html/deployment/inc_functions.php
@@ -17,6 +17,7 @@ $aParams = array();
 // ----------------------------------------------------------------------
 // verifiy config
 // ----------------------------------------------------------------------
+/*
     $aErrors=array();
     if (!isset($aConfig) || !is_array($aConfig)) {
         $aErrors[]="* \$aConfig does not exist. The config was not included before including " . __FILE__ . " in the request/ script.\n";
@@ -73,7 +74,7 @@ $aParams = array();
         die("FATAL ERROR on config.<br>" . implode("<br>\n", $aErrors));
     }
 
-
+*/
 // remark: $_SERVER does not exist in CLI
 if (isset($_SERVER) && is_array($_SERVER) && array_key_exists("REQUEST_URI", $_SERVER)) {
     /*