diff --git a/hooks/templates/dummyfile.erb b/hooks/templates/dummyfile.erb new file mode 100644 index 0000000000000000000000000000000000000000..5af068ff80838ff8a5b389502876ade9633d47ad --- /dev/null +++ b/hooks/templates/dummyfile.erb @@ -0,0 +1,9 @@ +Hier ist ein Testfile +Platzhalter + +DB-Host: <%= $dbhost ?> +DB-Schema: <%= $dbname ?> +DB-User: <%= $dbuser ?> +DB-Passwort: <%= $dbpassword ?> + +oder als URL: mysql://<%= $dbuser ?> \ No newline at end of file diff --git a/public_html/deployment/act_deploy.php b/public_html/deployment/act_deploy.php index e4a92ab8bb8c349776024e2853d40b2e81bbd213..49047fde34fb5bfb37dd8cc180afbff8671152dc 100644 --- a/public_html/deployment/act_deploy.php +++ b/public_html/deployment/act_deploy.php @@ -26,7 +26,7 @@ if (array_key_exists("confirm", $aParams)) { $sOut.=' <p> in der Queue:<br> - <pre>'.print_r($aPhaseData["onhold"], true).'</pre> + '.$oPrj->renderPhaseDetail($sPhase, "onhold", false).' </p> '; diff --git a/public_html/deployment/classes/html.tpl.php b/public_html/deployment/classes/html.tpl.php index 700970a98015fe79de73605836f8ea101080a8e5..381690b69dc273de87fb1244b4b118c258a26186 100644 --- a/public_html/deployment/classes/html.tpl.php +++ b/public_html/deployment/classes/html.tpl.php @@ -120,7 +120,7 @@ padding: 4px; } - a.info span{ display: none; position: absolute;} + a.info span{ display: none; position: absolute; background: #fff; PADDING: 0.5em; box-shadow: 0 0 10px #aaa;} a.info:hover span{ display: block; text-decoration: none;} a.info:hover { text-decoration: none;} diff --git a/public_html/deployment/classes/project.class.php b/public_html/deployment/classes/project.class.php index 47055cc1d0f11dda5b4209501cfd9190784f8144..3d6e9fea92d486dd7a1d01d491015f68f16769a7 100644 --- a/public_html/deployment/classes/project.class.php +++ b/public_html/deployment/classes/project.class.php @@ -435,13 +435,12 @@ class project { $aTmp[$sKey] = array(); if (file_exists($sJsonfile)) { $aJson = json_decode(file_get_contents($sJsonfile), true); - if (array_key_exists("timestamp", $aJson)) { + if (array_key_exists("version", $aJson)) { $aTmp[$sKey] = $aJson; $aTmp[$sKey]["infofile"] = $sJsonfile; - $aTmp[$sKey]["version"] = $aJson["timestamp"]; $aTmp[$sKey]["ok"] = 1; } else { - $aTmp[$sKey]["error"] = "info file $sJsonfile exists but is corrupt (no timestamp)." . print_r($aJson, true); + $aTmp[$sKey]["error"] = "info file $sJsonfile exists but is corrupt (no version).<pre>" . print_r($aJson, true) ."</pre>"; } } else { $aTmp[$sKey]["info"] = "No package is waiting in the queue."; @@ -456,14 +455,13 @@ class project { $sPkgfile = $this->_getPackagefile($sPhase, $sKey); if (file_exists($sPkgfile)) { $aJson = json_decode(file_get_contents($sJsonfile), true); - if (array_key_exists("timestamp", $aJson)) { + if (array_key_exists("version", $aJson)) { $aTmp[$sKey] = $aJson; $aTmp[$sKey]["infofile"] = $sJsonfile; $aTmp[$sKey]["packagefile"] = $sPkgfile; - $aTmp[$sKey]["version"] = $aJson["timestamp"]; $aTmp[$sKey]["ok"] = 1; } else { - $aTmp[$sKey]["error"] = "info file $sJsonfile exists but is corrupt (no timestamp)." . print_r($aJson, true); + $aTmp[$sKey]["error"] = "info file $sJsonfile exists but is corrupt (no version).<pre>" . print_r($aJson, true)."</pre>"; } } else { $aTmp[$sKey]["error"] = "package file was not found: $sPkgfile"; @@ -481,13 +479,12 @@ class project { $sJsonData = @file_get_contents($sJsonUrl); if ($sJsonData) { $aJson = json_decode($sJsonData, true); - if (array_key_exists("timestamp", $aJson)) { + if (array_key_exists("version", $aJson)) { $aTmp[$sKey] = $aJson; $aTmp[$sKey]["infofile"] = $sJsonUrl; - $aTmp[$sKey]["version"] = $aJson["timestamp"]; $aTmp[$sKey]["ok"] = 1; } else { - $aTmp[$sKey]["error"] = "json url was readable $sJsonUrl but is corrupt (no timestamp)." . print_r($aJson, true); + $aTmp[$sKey]["error"] = "json url was readable $sJsonUrl but is corrupt (no version).<pre>" . print_r($aJson, true)."</pre>"; } } else { $aTmp[$sKey]["error"] = "json url not readable $sJsonUrl"; @@ -708,8 +705,12 @@ class project { $sReturn.=$this->_execAndSend("ls -lisa $sTempDir"); // fetch version infos - $sVersioninfo = str_replace("\n", "<br>", shell_exec("cd $sTempDir && git log -1")); - $sReturn.=$this->getBox("info", $sVersioninfo); + + $sRevision = shell_exec("cd $sTempDir && git log -n 1 --pretty=format:\"%H\""); + $sCommitMsg = shell_exec("cd $sTempDir && git log -1"); + $sCommitMsg = str_replace("\n", "<br>", $sCommitMsg); + $sCommitMsg = str_replace('"', """, $sCommitMsg); + $sReturn.=$this->getBox("info", $sCommitMsg); break; @@ -758,7 +759,7 @@ class project { $sReturn.="<h3>cleanup project</h3>"; $sReturn.=$this->_execAndSend("cd $sTempDir && rm -rf .git"); // $sReturn.=$this->_execAndSend("cd $sTempDir && rm -rf .svn"); - $sReturn.=$this->_execAndSend("find $sTempDir -type d -name '.svn' -exec rm -rf {} \;"); + // $sReturn.=$this->_execAndSend("find $sTempDir -type d -name '.svn' -exec rm -rf {} \;"); // public_html must exist @@ -797,8 +798,9 @@ class project { $sInfos = '{ "date": "' . $sTs . '", - "timestamp": "' . $sTs2 . '", - "revision": "' . $sVersioninfo . '", + "version": "' . $sTs2 . '", + "revision": "' . $sRevision . '", + "message": "' . $sCommitMsg . '", "user": "' . $aParams["inputUser"] . '", "remark": "' . $aParams["inputComment"] . '" }'; @@ -819,12 +821,24 @@ class project { return $sReturn; } + // create tgz archive $sReturn.="create archive $sPackageFileArchiv<br>"; $sReturn.=$this->_execAndSend("cd $sTempDir && tar -czf $sPackageFileArchiv ."); + + // write info file (.json) $sReturn.="writing info file into archive...<br>"; file_put_contents($sInfoFileArchiv, $sInfos); + + // copy template files + if (file_exists($sTempDir . '/hooks/templates/')) { + $sReturn.="put templatesfile into archive...<br>"; + $sReturn.=$this->_execAndSend("cp $sTempDir/hooks/templates/* ". $this->_getArchiveDir($sTs2)); + } else { + $sReturn.="SKIP put templatesfile into archive - $sTempDir/hooks/templates/ does not exist.<br>"; + } + $sReturn.="<br>Created Archive files:<br>"; - $sReturn.=$this->_execAndSend("ls -l $sPackageFileArchiv $sInfoFileArchiv"); + $sReturn.=$this->_execAndSend("ls -l " . $this->_getArchiveDir($sTs2)); if (!$this->_iRcAll == 0) { return $this->getBox("error", 'creation failed One of the commands failed (see below).<br>You can ask the sysadmins and analyze with them the created temp directory "' . $sTempDir . '".' . $sReturn); @@ -832,7 +846,7 @@ class project { $sReturn.="<h3>Cleanup</h3>"; - $sReturn.="<h3>SKIP cleanup $sTempDir</h3>"; + $sReturn.="<h3>cleanup $sTempDir</h3>"; $sReturn.=$this->_execAndSend("rm -rf $sTempDir"); $sReturn.="<h3>cleanup Archive</h3>removing the oldest unused packages ..."; $sReturn.='<pre>'. print_r($this->cleanupArchive(), true).'</pre>'; @@ -1116,9 +1130,10 @@ class project { * @param string $sPhase phase * @param string $sPlace name of the place; one of onhold|ready4deployment|deployed * @param bool $bActions draw action links (deploy, accept) on/ off + * @param bool $bLong use long variant to display infos? * @return string|boolean */ - public function renderPhaseDetail($sPhase, $sPlace, $bActions=true){ + public function renderPhaseDetail($sPhase, $sPlace, $bActions=true, $bLong=true){ if (!$sPhase) { return false; } if (!$sPlace) { return false; } @@ -1130,12 +1145,19 @@ class project { $aData=$aDataPhase[$sPlace]; if (array_key_exists("ok", $aData) && array_key_exists("version", $aData)) { // TODO: getChecksumDiv anhand der Repo-Versionsnummer - dann kann man beim build auch die Farbe mit dem Repo HEAD vergleichen - $sReturn = ' - '.$this->getChecksumDiv($aData["version"]).' - <i class="icon-calendar"></i> Build vom ' . date("d.m.Y H:i:s", strtotime($aData["date"])) . '<br> - <a href="#" class="info"><i class="icon-tag"></i> Revision:<span><pre>' . $aData["revision"] . '</pre></span></a><br> + $sReturn .= ' + '.$this->getChecksumDiv($aData["revision"]).' + <i class="icon-calendar"></i> Build vom ' . date("d.m.Y H:i:s", strtotime($aData["date"])) . '<br>'; + if ($bLong){ + $sReturn.='<i class="icon-tag"></i> Revision: ' . $aData["revision"] . '<br> + Commit:<br><pre>' . $aData["message"] . '</pre> <!-- Anm.: ' . $aTmp[$h]["remark"] . '<br> -->'; - + } else { + $sReturn.='<a href="#" class="info">Info<span>' + . '<i class="icon-tag"></i> Revision: ' . $aData["revision"] . '<br>' + . '<i class="icon-tag"></i> Message:<pre>' . $aData["message"] . '</pre>' + . '</span></a>'; + } switch ($sPlace) { case "onhold": @@ -1161,9 +1183,13 @@ class project { </div>'; } else { if (array_key_exists("error", $aData)) { - $sReturn.= '<div class="error">' - . '<a href="#" class="info"><i class="icon-exclamation-sign"></i> FEHLER:<span>' . $aData["error"] . '</span></a>' - . '</div>'; + $sReturn.= '<div class="error">'; + // if ($bLong and true){ + // $sReturn.= '<i class="icon-exclamation-sign"></i> FEHLER:<br>' . $aData["error"] . ''; + // } else { + $sReturn.= '<a href="#" class="info"><i class="icon-exclamation-sign"></i> FEHLER:<span>' . $aData["error"] . '</span></a>'; + // } + $sReturn.= '</div>'; } else if (array_key_exists("warning", $aData)) { $sReturn.= '<div class="warning"><i class="icon-info-sign"></i> WARNUNG:<br>' . $aData["warning"] . '</div>'; } else { @@ -1189,9 +1215,10 @@ class project { * render html for a row with td for all places of a phase * @param string $sPhase phase * @param bool $bActions draw action links (deploy, accept) on/ off + * @param bool $bLong use long variant to display infos? * @return string|boolean */ - public function renderAllPhaseDetails($sPhase, $bActions=true){ + public function renderAllPhaseDetails($sPhase, $bActions=true, $bLong=true){ if (!$sPhase) { return false; } if (!$this->isActivePhase($sPhase)) { return ' @@ -1202,7 +1229,7 @@ class project { $sRow2=false; foreach ($this->_aPlaces as $sPlace=>$sLabel){ - $sRow2.='<td class="'.$sPhase.' tdphase td'.$this->_aConfig["id"].'">'.$this->renderPhaseDetail($sPhase, $sPlace, $bActions).'</td>'; + $sRow2.='<td class="'.$sPhase.' tdphase td'.$this->_aConfig["id"].'">'.$this->renderPhaseDetail($sPhase, $sPlace, $bActions, $bLong).'</td>'; } return $sRow2; } @@ -1211,19 +1238,18 @@ class project { * @return string */ public function renderRepoInfo(){ - // return "TODO: fix or delete project::showRepoInfo()<br>"; $sReturn=""; switch ($this->_aPrjConfig["build"]["type"]) { case "git": $sKeyfile = dirname(dirname(__file__)) . "/" . $this->_aPrjConfig["build"]["keyfile"]; $sWrapper = dirname(dirname(dirname(dirname(__file__)))) . "/shellscripts/gitsshwrapper.sh"; - // $sReturn.=$this->_execAndSend("export GIT_SSH=$sWrapper ; export PKEY=$sKeyfile; git ls-remote --heads " . $this->_aPrjConfig["build"]["ssh"]); - $sGitCmd="git ls-remote --heads " . $this->_aPrjConfig["build"]["ssh"] . " master"; - $sReturn.="$sGitCmd<br><pre>"; - $sReturn.= shell_exec("export GIT_SSH=$sWrapper ; export PKEY=$sKeyfile; $sGitCmd"); - $sReturn."</pre>"; - // $sVersioninfo = str_replace("\n", "<br>", shell_exec("cd $sTempDir && git log -1")); + $sGitCmd="git ls-remote --heads " . $this->_aPrjConfig["build"]["ssh"] . " master | awk '{ print $1 }'"; + $sRevision=shell_exec("export GIT_SSH=$sWrapper ; export PKEY=$sKeyfile; $sGitCmd"); + $sRevision=trim($sRevision); + $sReturn.=$this->getChecksumDiv($sRevision); + $sReturn.= '<i class="icon-tag"></i> Revision: '.$sRevision; + // $sReturn.="<br>$sGitCmd<br>"; break; diff --git a/public_html/deployment/classes/projectlist.class.php b/public_html/deployment/classes/projectlist.class.php index 09eda5a2fc7c357f4dcaddde8bae2f714121ad14..c226cf7b9a20efc72dd714a85cff8b1722d19c3b 100644 --- a/public_html/deployment/classes/projectlist.class.php +++ b/public_html/deployment/classes/projectlist.class.php @@ -119,7 +119,7 @@ class projectlist { // loop over phases ... foreach (array_keys($this->_aPhases) as $sPhase) { - $sOutPhases.=$oPrj->renderAllPhaseDetails($sPhase,true); + $sOutPhases.=$oPrj->renderAllPhaseDetails($sPhase,true,false); } // render output