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

- test progress 5

- rollback try 1

DO NOT DEPLOY ON LIVE
parent 40c66dcf
No related branches found
No related tags found
No related merge requests found
......@@ -295,6 +295,21 @@ class project {
return $this->_getProjectArchiveDir() . '/' . $sTimestamp;
}
private function _getArchiveInfos($sTimestamp) {
if (!$sTimestamp) {
die("ERROR: getArchiveDir timestamp is required");
}
$sInfoFile = $this->_getArchiveDir($sTimestamp) . '/' . $this->_aPrjConfig["fileprefix"] . '.json';
if (!file_exists($sInfoFile)){
return "ERROR: $sInfoFile does not exist";
}
$aJson = json_decode(file_get_contents($sInfoFile), true);
if (is_array($aJson) && array_key_exists("version", $aJson)) {
return $aJson;
}
return "ERROR: $sInfoFile is not a JSON file";
}
/**
* get the directory for archive files of this project
* @return string
......@@ -689,7 +704,6 @@ class project {
$sGitCmd.="git log -1 origin/master ; ";
$sReturn.= shell_exec($sGitCmd);
// echo "<pre><strong>$sGitCmd</strong><br>$sReturn</pre>";
// revision aus der Ausgabe ziehen
$sRevision = false;
if (preg_match('#commit\ (.*)#', $sReturn, $aRev)) {
......@@ -817,7 +831,8 @@ class project {
* @return boolean
*/
private function _TempFill($sData, $aActions = array()) {
if (!$this->_sProcessTempOut) return false;
if (!$this->_sProcessTempOut)
return false;
$sActions = '';
if (count($aActions)) {
for ($i = 0; $i < count($aActions["actions"]); $i++) {
......@@ -845,14 +860,14 @@ class project {
* @return boolean
*/
private function _TempDelete() {
if (!$this->_sProcessTempOut) return false;
if (!$this->_sProcessTempOut)
return false;
if (file_exists($this->_sProcessTempOut)) {
unlink($this->_sProcessTempOut);
}
return file_exists($this->_sProcessTempOut);
}
/**
* Build a new package for the deployment. It will be put to the queue
* of the first active phase (i.e. preview).
......@@ -894,7 +909,8 @@ class project {
if (count($aDirs)) {
$sReturn.='<h3>Cleanup older failed builds</h3><pre>' . print_r($aDirs, true) . '</pre>';
}
$aActionList['iActive']++; $this->_TempFill($sReturn, $aActionList);
$aActionList['iActive'] ++;
$this->_TempFill($sReturn, $aActionList);
// --------------------------------------------------
// create workdir
......@@ -916,7 +932,8 @@ class project {
return $this->getBox("error", "$sTempDir was not created." . $sReturn);
}
$this->_iRcAll = 0;
$aActionList['iActive']++; $this->_TempFill($sReturn, $aActionList);
$aActionList['iActive'] ++;
$this->_TempFill($sReturn, $aActionList);
// --------------------------------------------------
// checkout
......@@ -958,7 +975,8 @@ class project {
return $this->getBox("error", "checkout failed.</h3>One of the commands failed (see above).<br>You can ask the sysadmins and analyze with them the created temp directory &quot;' . $sTempDir . '&quot;." . $sReturn);
}
$sReturn.=$this->getBox("success", "Checkout OK!");
$aActionList['iActive']++; $this->_TempFill($sReturn, $aActionList);
$aActionList['iActive'] ++;
$this->_TempFill($sReturn, $aActionList);
// --------------------------------------------------
......@@ -976,7 +994,8 @@ class project {
} else {
$sReturn.='SKIP. Hook was not found.<br>';
}
$aActionList['iActive']++; $this->_TempFill($sReturn, $aActionList);
$aActionList['iActive'] ++;
$this->_TempFill($sReturn, $aActionList);
// --------------------------------------------------
......@@ -991,7 +1010,8 @@ class project {
} else {
$sReturn.='No defaults ... starting with empty directory.<br>';
}
$aActionList['iActive']++; $this->_TempFill($sReturn, $aActionList);
$aActionList['iActive'] ++;
$this->_TempFill($sReturn, $aActionList);
// --------------------------------------------------
// execute hook
......@@ -1008,7 +1028,8 @@ class project {
} else {
$sReturn.='SKIP. Hook was not found.<br>';
}
$aActionList['iActive']++; $this->_TempFill($sReturn, $aActionList);
$aActionList['iActive'] ++;
$this->_TempFill($sReturn, $aActionList);
// --------------------------------------------------
......@@ -1042,7 +1063,8 @@ class project {
return $this->getBox("error", "build failed - working directory has errors and is not ready to create package.<br>You can ask the sysadmins and analyze with them the created temp directory &quot;$sTempDir&quot;" . $sReturn);
}
$sReturn.=$this->getBox("success", "preparations ok - directory is ready for packaging now.");
$aActionList['iActive']++; $this->_TempFill($sReturn, $aActionList);
$aActionList['iActive'] ++;
$this->_TempFill($sReturn, $aActionList);
// --------------------------------------------------
// create package
......@@ -1109,7 +1131,8 @@ class project {
$this->_TempDelete();
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);
}
$aActionList['iActive']++; $this->_TempFill($sReturn, $aActionList);
$aActionList['iActive'] ++;
$this->_TempFill($sReturn, $aActionList);
$sReturn.="<h3>Cleanup</h3>";
......@@ -1119,7 +1142,8 @@ class project {
$sReturn.='<pre>' . print_r($this->cleanupArchive(), true) . '</pre>';
$sReturn.=$this->getBox("success", "Build finished successfully.");
$aActionList['iActive']++; $this->_TempFill($sReturn, $aActionList);
$aActionList['iActive'] ++;
$this->_TempFill($sReturn, $aActionList);
$sReturn.=$this->queue($sFirstLevel, $sTs2);
$this->_TempDelete();
......@@ -1170,7 +1194,8 @@ class project {
if (!file_exists($sLinkTarget)) {
die("ERROR: Queuing failed - version $sVersion is invalid. The directory $sLinkTarget does not exist.");
}
$aActionList['iActive']++; $this->_TempFill($sReturn, $aActionList);
$aActionList['iActive'] ++;
$this->_TempFill($sReturn, $aActionList);
// --------------------------------------------------
// remove existing version
......@@ -1180,7 +1205,8 @@ class project {
$sReturn.="removing existing version<br>";
$sReturn.=$this->_execAndSend("rm -f $sLinkName");
}
$aActionList['iActive']++; $this->_TempFill($sReturn, $aActionList);
$aActionList['iActive'] ++;
$this->_TempFill($sReturn, $aActionList);
// --------------------------------------------------
// create the new link
......@@ -1188,7 +1214,8 @@ class project {
$sReturn.="linking to new version <br>";
$sReturn.=$this->_execAndSend("ln -s $sLinkTarget $sLinkName");
$sReturn.=$this->_execAndSend("ls -l $sLinkName | fgrep $sLinkTarget");
$aActionList['iActive']++; $this->_TempFill($sReturn, $aActionList);
$aActionList['iActive'] ++;
$this->_TempFill($sReturn, $aActionList);
if (!$this->_iRcAll == 0) {
......@@ -1266,7 +1293,8 @@ class project {
return $sReturn;
}
$this->_TempFill($sReturn);
$aActionList['iActive']++; $this->_TempFill($sReturn, $aActionList);
$aActionList['iActive'] ++;
$this->_TempFill($sReturn, $aActionList);
// --------------------------------------------------
......@@ -1318,7 +1346,8 @@ class project {
}
} // foreach
}
$aActionList['iActive']++; $this->_TempFill($sReturn, $aActionList);
$aActionList['iActive'] ++;
$this->_TempFill($sReturn, $aActionList);
// TODO: run puppet agent on target server(s) - for preview only
if (array_key_exists("puppethost", $this->_aPrjConfig["phases"][$sPhase]) && $this->_aPrjConfig["phases"][$sPhase]["puppethost"]
......@@ -1332,7 +1361,8 @@ class project {
} else {
$sReturn.="SKIP: no puppet host was defined. The deployment was done and will be installed soon (within 30min).<br>";
}
$aActionList['iActive']++; $this->_TempFill($sReturn, $aActionList);
$aActionList['iActive'] ++;
$this->_TempFill($sReturn, $aActionList);
$sReturn.="<br>";
$sReturn.=$this->getBox("success", "SUCCESS: deployment was done.");
......@@ -1539,10 +1569,13 @@ class project {
);
// fuer wen ist der Link:
$sRole = '';
if ($sFunction=="build") {$sRole = 'developer'; }
if ($sFunction == "build") {
$sRole = 'developer';
}
if ($sFunction == "accept") {
$sRole = 'developer';
if ($sNext=="live")$sRole = 'pl';
if ($sNext == "live")
$sRole = 'pl';
}
$sClass = $sPhase;
......@@ -1810,36 +1843,69 @@ class project {
public function renderVersionUsage() {
$sReturn = false;
$sRowHead1 = false;
$sRowHead2 = false;
$sRowHead2 = '';
if (!count($this->getVersions())) {
return $this->getBox("info", "Für dieses Projekt wurde noch kein Paket erzeugt.");
}
foreach ($this->getActivePhases() as $sPhase) {
$sRowHead1.='<th class="' . $sPhase . '" colspan="' . count($this->_aPlaces) . '">' . $sPhase . '</th>';
$sRowHead2.=$this->renderPlacesAsTd($sPhase);
$sRowHead1.='<th class="' . $sPhase . '" colspan="' . (count($this->_aPlaces) + 1) . '">' . $sPhase . '</th>';
$sRowHead2.='<td></td>' . $this->renderPlacesAsTd($sPhase);
}
$aVersionData = array();
$sLastVersion=false;
foreach ($this->getVersions() as $sVersion => $aData) {
$sReturn.='<tr>';
$sReturn.='<td>' . $sVersion . '</td>';
foreach ($this->getActivePhases() as $sPhase) {
/*
$aJson = json_decode(file_get_contents($sJsonfile), true);
if (is_array($aJson) && array_key_exists("version", $aJson)) {
$aTmp[$sKey] = $aJson;
}
*
*/
$aTmp=$this->_getArchiveInfos($sVersion);
$sInfos=$aTmp;
if (is_array($aTmp) && array_key_exists("message", $aTmp)){
$sInfos='<pre>' . $aData["message"] . '</pre>';
}
$sReturn.='<td>' . $sVersion .'<br>'. $sInfos .'</td>';
foreach ($this->getActivePhases() as $sPhase) {
$bCanRollback = false;
$sTLine = '';
foreach (array_keys($this->_aPlaces) as $sPlace) {
$bFound = false;
if (is_array($aData) && count($aData))
if (is_array($aData) && count($aData)) {
foreach ($aData as $i => $aPhaseUsage) {
if ($aPhaseUsage["phase"] == $sPhase && $aPhaseUsage["place"] == $sPlace
)
$bFound = true;
}
}
if ($bFound) {
$sReturn.='<td class="' . $sPhase . '" style="text-align: center;">X</td>';
$sTLine.='<td class="' . $sPhase . '" style="text-align: center;">X</td>';
$bCanRollback = false;
} else {
$sReturn.='<td> </td>';
$bCanRollback = true;
if ($sLastVersion && !$aVersionData[$sLastVersion][$sPhase]["rollback"]){
$bCanRollback = false;
}
$sTLine.='<td> </td>';
}
$aVersionData[$sVersion][$sPhase]["rollback"]=$bCanRollback;
}
// TODO: Rollback-Link generieren
$sReturn.=$bCanRollback ? '<td>Rollback</td>' : '<td title="kein Rollback">-</td>';
$sReturn.=$sTLine;
}
$sLastVersion=$sVersion;
$sReturn.='</tr>';
}
// echo "<pre>" . print_r($aVersionData, true) . "</pre>";
echo "<pre>" . print_r($this->getVersions(), true) . "</pre>";
unset($aVersionData);
$sReturn = 'Die nachfolgende Tabelle zeigt die bereits erzeugten Pakete an und wo diese verwendet werden.<br><br>'
. '<table>'
. '<thead><tr><td>Version</td>'
......@@ -2008,7 +2074,6 @@ class project {
. $sRepoCheck
. '</div></fieldset>',
),
'input' . $i++ => array(
'type' => 'text',
'name' => 'build[webaccess]',
......
......@@ -246,6 +246,7 @@ class projectlist {
onchange="filterTable();"
onKeypress="filterTable(); "
onKeyup="filterTable(); "
title="gesucht wird in Projektnamen, Beschreibungen, Commit-Messages"
>
<span class="view viewextended">
&nbsp;&nbsp;&nbsp;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment