Skip to content
Snippets Groups Projects
Commit e9004159 authored by hahn's avatar hahn
Browse files

- kleinere Ansicht der Phasen in der Übersichtsseite

- neu Infofiles enthalten einen Eintrag auch für die Revision-Nr
- Farbbalken aus Revision Nr.
- Build(): Anzeige der Revision in der Versionskontrolle
- Build(): Templates aus dem Hook werden mit ins Archiv übernommen
parent dbfca960
Branches
No related tags found
No related merge requests found
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
...@@ -26,7 +26,7 @@ if (array_key_exists("confirm", $aParams)) { ...@@ -26,7 +26,7 @@ if (array_key_exists("confirm", $aParams)) {
$sOut.=' $sOut.='
<p> <p>
in der Queue:<br> in der Queue:<br>
<pre>'.print_r($aPhaseData["onhold"], true).'</pre> '.$oPrj->renderPhaseDetail($sPhase, "onhold", false).'
</p> </p>
'; ';
......
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
padding: 4px; 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 span{ display: block; text-decoration: none;}
a.info:hover { text-decoration: none;} a.info:hover { text-decoration: none;}
......
...@@ -435,13 +435,12 @@ class project { ...@@ -435,13 +435,12 @@ class project {
$aTmp[$sKey] = array(); $aTmp[$sKey] = array();
if (file_exists($sJsonfile)) { if (file_exists($sJsonfile)) {
$aJson = json_decode(file_get_contents($sJsonfile), true); $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] = $aJson;
$aTmp[$sKey]["infofile"] = $sJsonfile; $aTmp[$sKey]["infofile"] = $sJsonfile;
$aTmp[$sKey]["version"] = $aJson["timestamp"];
$aTmp[$sKey]["ok"] = 1; $aTmp[$sKey]["ok"] = 1;
} else { } 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 { } else {
$aTmp[$sKey]["info"] = "No package is waiting in the queue."; $aTmp[$sKey]["info"] = "No package is waiting in the queue.";
...@@ -456,14 +455,13 @@ class project { ...@@ -456,14 +455,13 @@ class project {
$sPkgfile = $this->_getPackagefile($sPhase, $sKey); $sPkgfile = $this->_getPackagefile($sPhase, $sKey);
if (file_exists($sPkgfile)) { if (file_exists($sPkgfile)) {
$aJson = json_decode(file_get_contents($sJsonfile), true); $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] = $aJson;
$aTmp[$sKey]["infofile"] = $sJsonfile; $aTmp[$sKey]["infofile"] = $sJsonfile;
$aTmp[$sKey]["packagefile"] = $sPkgfile; $aTmp[$sKey]["packagefile"] = $sPkgfile;
$aTmp[$sKey]["version"] = $aJson["timestamp"];
$aTmp[$sKey]["ok"] = 1; $aTmp[$sKey]["ok"] = 1;
} else { } 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 { } else {
$aTmp[$sKey]["error"] = "package file was not found: $sPkgfile"; $aTmp[$sKey]["error"] = "package file was not found: $sPkgfile";
...@@ -481,13 +479,12 @@ class project { ...@@ -481,13 +479,12 @@ class project {
$sJsonData = @file_get_contents($sJsonUrl); $sJsonData = @file_get_contents($sJsonUrl);
if ($sJsonData) { if ($sJsonData) {
$aJson = json_decode($sJsonData, true); $aJson = json_decode($sJsonData, true);
if (array_key_exists("timestamp", $aJson)) { if (array_key_exists("version", $aJson)) {
$aTmp[$sKey] = $aJson; $aTmp[$sKey] = $aJson;
$aTmp[$sKey]["infofile"] = $sJsonUrl; $aTmp[$sKey]["infofile"] = $sJsonUrl;
$aTmp[$sKey]["version"] = $aJson["timestamp"];
$aTmp[$sKey]["ok"] = 1; $aTmp[$sKey]["ok"] = 1;
} else { } 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 { } else {
$aTmp[$sKey]["error"] = "json url not readable $sJsonUrl"; $aTmp[$sKey]["error"] = "json url not readable $sJsonUrl";
...@@ -708,8 +705,12 @@ class project { ...@@ -708,8 +705,12 @@ class project {
$sReturn.=$this->_execAndSend("ls -lisa $sTempDir"); $sReturn.=$this->_execAndSend("ls -lisa $sTempDir");
// fetch version infos // 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('"', "&quot;", $sCommitMsg);
$sReturn.=$this->getBox("info", $sCommitMsg);
break; break;
...@@ -758,7 +759,7 @@ class project { ...@@ -758,7 +759,7 @@ class project {
$sReturn.="<h3>cleanup project</h3>"; $sReturn.="<h3>cleanup project</h3>";
$sReturn.=$this->_execAndSend("cd $sTempDir && rm -rf .git"); $sReturn.=$this->_execAndSend("cd $sTempDir && rm -rf .git");
// $sReturn.=$this->_execAndSend("cd $sTempDir && rm -rf .svn"); // $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 // public_html must exist
...@@ -797,8 +798,9 @@ class project { ...@@ -797,8 +798,9 @@ class project {
$sInfos = '{ $sInfos = '{
"date": "' . $sTs . '", "date": "' . $sTs . '",
"timestamp": "' . $sTs2 . '", "version": "' . $sTs2 . '",
"revision": "' . $sVersioninfo . '", "revision": "' . $sRevision . '",
"message": "' . $sCommitMsg . '",
"user": "' . $aParams["inputUser"] . '", "user": "' . $aParams["inputUser"] . '",
"remark": "' . $aParams["inputComment"] . '" "remark": "' . $aParams["inputComment"] . '"
}'; }';
...@@ -819,12 +821,24 @@ class project { ...@@ -819,12 +821,24 @@ class project {
return $sReturn; return $sReturn;
} }
// create tgz archive
$sReturn.="create archive $sPackageFileArchiv<br>"; $sReturn.="create archive $sPackageFileArchiv<br>";
$sReturn.=$this->_execAndSend("cd $sTempDir && tar -czf $sPackageFileArchiv ."); $sReturn.=$this->_execAndSend("cd $sTempDir && tar -czf $sPackageFileArchiv .");
// write info file (.json)
$sReturn.="writing info file into archive...<br>"; $sReturn.="writing info file into archive...<br>";
file_put_contents($sInfoFileArchiv, $sInfos); 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.="<br>Created Archive files:<br>";
$sReturn.=$this->_execAndSend("ls -l $sPackageFileArchiv $sInfoFileArchiv"); $sReturn.=$this->_execAndSend("ls -l " . $this->_getArchiveDir($sTs2));
if (!$this->_iRcAll == 0) { 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 &quot;' . $sTempDir . '&quot;.' . $sReturn); 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 &quot;' . $sTempDir . '&quot;.' . $sReturn);
...@@ -832,7 +846,7 @@ class project { ...@@ -832,7 +846,7 @@ class project {
$sReturn.="<h3>Cleanup</h3>"; $sReturn.="<h3>Cleanup</h3>";
$sReturn.="<h3>SKIP cleanup $sTempDir</h3>"; $sReturn.="<h3>cleanup $sTempDir</h3>";
$sReturn.=$this->_execAndSend("rm -rf $sTempDir"); $sReturn.=$this->_execAndSend("rm -rf $sTempDir");
$sReturn.="<h3>cleanup Archive</h3>removing the oldest unused packages ..."; $sReturn.="<h3>cleanup Archive</h3>removing the oldest unused packages ...";
$sReturn.='<pre>'. print_r($this->cleanupArchive(), true).'</pre>'; $sReturn.='<pre>'. print_r($this->cleanupArchive(), true).'</pre>';
...@@ -1116,9 +1130,10 @@ class project { ...@@ -1116,9 +1130,10 @@ class project {
* @param string $sPhase phase * @param string $sPhase phase
* @param string $sPlace name of the place; one of onhold|ready4deployment|deployed * @param string $sPlace name of the place; one of onhold|ready4deployment|deployed
* @param bool $bActions draw action links (deploy, accept) on/ off * @param bool $bActions draw action links (deploy, accept) on/ off
* @param bool $bLong use long variant to display infos?
* @return string|boolean * @return string|boolean
*/ */
public function renderPhaseDetail($sPhase, $sPlace, $bActions=true){ public function renderPhaseDetail($sPhase, $sPlace, $bActions=true, $bLong=true){
if (!$sPhase) { return false; } if (!$sPhase) { return false; }
if (!$sPlace) { return false; } if (!$sPlace) { return false; }
...@@ -1130,12 +1145,19 @@ class project { ...@@ -1130,12 +1145,19 @@ class project {
$aData=$aDataPhase[$sPlace]; $aData=$aDataPhase[$sPlace];
if (array_key_exists("ok", $aData) && array_key_exists("version", $aData)) { 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 // TODO: getChecksumDiv anhand der Repo-Versionsnummer - dann kann man beim build auch die Farbe mit dem Repo HEAD vergleichen
$sReturn = ' $sReturn .= '
'.$this->getChecksumDiv($aData["version"]).' '.$this->getChecksumDiv($aData["revision"]).'
<i class="icon-calendar"></i> Build vom ' . date("d.m.Y H:i:s", strtotime($aData["date"])) . '<br> <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> if ($bLong){
$sReturn.='<i class="icon-tag"></i> Revision: ' . $aData["revision"] . '<br>
Commit:<br><pre>' . $aData["message"] . '</pre>
<!-- Anm.: ' . $aTmp[$h]["remark"] . '<br> -->'; <!-- 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) { switch ($sPlace) {
case "onhold": case "onhold":
...@@ -1161,9 +1183,13 @@ class project { ...@@ -1161,9 +1183,13 @@ class project {
</div>'; </div>';
} else { } else {
if (array_key_exists("error", $aData)) { if (array_key_exists("error", $aData)) {
$sReturn.= '<div class="error">' $sReturn.= '<div class="error">';
. '<a href="#" class="info"><i class="icon-exclamation-sign"></i> FEHLER:<span>' . $aData["error"] . '</span></a>' // if ($bLong and true){
. '</div>'; // $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)) { } else if (array_key_exists("warning", $aData)) {
$sReturn.= '<div class="warning"><i class="icon-info-sign"></i> WARNUNG:<br>' . $aData["warning"] . '</div>'; $sReturn.= '<div class="warning"><i class="icon-info-sign"></i> WARNUNG:<br>' . $aData["warning"] . '</div>';
} else { } else {
...@@ -1189,9 +1215,10 @@ class project { ...@@ -1189,9 +1215,10 @@ class project {
* render html for a row with td for all places of a phase * render html for a row with td for all places of a phase
* @param string $sPhase phase * @param string $sPhase phase
* @param bool $bActions draw action links (deploy, accept) on/ off * @param bool $bActions draw action links (deploy, accept) on/ off
* @param bool $bLong use long variant to display infos?
* @return string|boolean * @return string|boolean
*/ */
public function renderAllPhaseDetails($sPhase, $bActions=true){ public function renderAllPhaseDetails($sPhase, $bActions=true, $bLong=true){
if (!$sPhase) { return false; } if (!$sPhase) { return false; }
if (!$this->isActivePhase($sPhase)) { if (!$this->isActivePhase($sPhase)) {
return ' return '
...@@ -1202,7 +1229,7 @@ class project { ...@@ -1202,7 +1229,7 @@ class project {
$sRow2=false; $sRow2=false;
foreach ($this->_aPlaces as $sPlace=>$sLabel){ 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; return $sRow2;
} }
...@@ -1211,19 +1238,18 @@ class project { ...@@ -1211,19 +1238,18 @@ class project {
* @return string * @return string
*/ */
public function renderRepoInfo(){ public function renderRepoInfo(){
// return "TODO: fix or delete project::showRepoInfo()<br>";
$sReturn=""; $sReturn="";
switch ($this->_aPrjConfig["build"]["type"]) { switch ($this->_aPrjConfig["build"]["type"]) {
case "git": case "git":
$sKeyfile = dirname(dirname(__file__)) . "/" . $this->_aPrjConfig["build"]["keyfile"]; $sKeyfile = dirname(dirname(__file__)) . "/" . $this->_aPrjConfig["build"]["keyfile"];
$sWrapper = dirname(dirname(dirname(dirname(__file__)))) . "/shellscripts/gitsshwrapper.sh"; $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 | awk '{ print $1 }'";
$sGitCmd="git ls-remote --heads " . $this->_aPrjConfig["build"]["ssh"] . " master"; $sRevision=shell_exec("export GIT_SSH=$sWrapper ; export PKEY=$sKeyfile; $sGitCmd");
$sReturn.="$sGitCmd<br><pre>"; $sRevision=trim($sRevision);
$sReturn.= shell_exec("export GIT_SSH=$sWrapper ; export PKEY=$sKeyfile; $sGitCmd"); $sReturn.=$this->getChecksumDiv($sRevision);
$sReturn."</pre>"; $sReturn.= '<i class="icon-tag"></i> Revision: '.$sRevision;
// $sVersioninfo = str_replace("\n", "<br>", shell_exec("cd $sTempDir && git log -1")); // $sReturn.="<br>$sGitCmd<br>";
break; break;
......
...@@ -119,7 +119,7 @@ class projectlist { ...@@ -119,7 +119,7 @@ class projectlist {
// loop over phases ... // loop over phases ...
foreach (array_keys($this->_aPhases) as $sPhase) { foreach (array_keys($this->_aPhases) as $sPhase) {
$sOutPhases.=$oPrj->renderAllPhaseDetails($sPhase,true); $sOutPhases.=$oPrj->renderAllPhaseDetails($sPhase,true,false);
} }
// render output // render output
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment