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

- overview - filter link moved to top right

- revision fixed to top right
- fixed warning "headers already sent" 
- new: setup: show errors on top
- new try: read remote git log
parent 2d9ddd8a
No related branches found
No related tags found
No related merge requests found
......@@ -31,7 +31,10 @@ if (array_key_exists("confirm", $aParams)) {
Es wird ein neues Paket erstellt und f&uuml;r die Phase <em class="' . $sNext . '">' . $sNext . '</em> bereitgestellt.<br>
</p>';
$sRevison = $oPrj->getRepoRevision();
$sRevison=false;
$aRepodata = $oPrj->getRepoRevision();
if (is_array($aRepodata) && array_key_exists("revision", $aRepodata)) {
$sRevison = $aRepodata["revision"];
if (
array_key_exists("revision", $aPhaseData2["onhold"]) && $aPhaseData2["onhold"]["revision"] == $sRevison
) {
......@@ -42,6 +45,7 @@ if (array_key_exists("confirm", $aParams)) {
) {
$sOut.=getBox("warning", "Im Repo von [$sNext] ist die Version $sRevison bereits vorhanden!");
}
}
$sOut.='
<table>
<thead>
......@@ -76,6 +80,7 @@ if (array_key_exists("confirm", $aParams)) {
';
// Eingabe Kommentare zum Deployment
if ($sRevison) {
$sOut.='
<form action="?" method="post" enctype="multipart/form-data">
<input type="hidden" name="confirm" value="1">
......@@ -88,6 +93,7 @@ if (array_key_exists("confirm", $aParams)) {
</form>
';
}
}
$sOut.='<hr>' . aHome() . ' ' . aPrjHome();
......
......@@ -135,14 +135,16 @@ class project {
$sReturn = '';
$bUseHtml = $_SERVER ? true : false;
if ($bFlush) ob_implicit_flush(true);
if ($bFlush)
ob_implicit_flush(true);
// ob_end_flush();
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a pipe that the child will write to
);
if ($bFlush) flush();
if ($bFlush)
flush();
$process = proc_open($sCommand, $descriptorspec, $pipes, realpath('./'), array());
$sReturn.="[" . date("H:i:s d.m.Y") . "] ";
......@@ -153,11 +155,13 @@ class project {
if (is_resource($process)) {
while ($s = fgets($pipes[1])) {
$sReturn.=$s;
if ($bFlush) flush();
if ($bFlush)
flush();
}
while ($s = fgets($pipes[2])) {
$sErrors.=$s;
if ($bFlush) flush();
if ($bFlush)
flush();
}
}
if ($sErrors)
......@@ -175,7 +179,8 @@ class project {
$sReturn.='</pre>';
}
if ($bFlush) flush();
if ($bFlush)
flush();
return $sReturn;
}
......@@ -644,37 +649,45 @@ class project {
}
/**
* get current revision from remote repo
* @return string
* get current revision and log message from remote repo
* @return array
*/
public function getRepoRevision($bRefresh = false) {
$sReturn = "";
if (
array_key_exists("source", $this->_aData["phases"]) && $this->_aData["phases"]["source"] && $bRefresh == false
)
) {
return $this->_aData["phases"]["source"];
}
switch ($this->_aPrjConfig["build"]["type"]) {
case "git":
$sKeyfile = dirname(dirname(__file__)) . "/" . $this->_aPrjConfig["build"]["keyfile"];
$sWrapper = dirname(dirname(dirname(dirname(__file__)))) . "/shellscripts/gitsshwrapper.sh";
$sGitCmd = "git ls-remote --heads " . $this->_aPrjConfig["build"]["ssh"] . " master | awk '{ print $1 }'";
$sRevision = shell_exec("export GIT_SSH=$sWrapper ; export PKEY=$sKeyfile; $sGitCmd");
$sReturn = trim($sRevision);
$sGitCmd = "export GIT_SSH=$sWrapper ; ";
$sGitCmd.="export PKEY=$sKeyfile ; ";
$sGitCmd.="export testdir=/tmp/test_\$\$ ; set -vx ; ";
$sGitCmd.="export testdir=/tmp/test_\$\$ ; ";
// $sGitCmd.="set -vx ; ";
$sGitCmd.="mkdir \$testdir && cd \$testdir && ";
$sGitCmd.="git init && ";
$sGitCmd.="git remote add origin " . $this->_aPrjConfig["build"]["ssh"] . " && ";
// $sGitCmd.="git clean -f && ";
$sGitCmd.="git fetch && ";
// $sGitCmd.="sleep 1 ; ";
$sGitCmd.="git log -1 --format=fuller origin/master remote; ";
$sGitCmd.="git fetch 2>&1 && ";
$sGitCmd.="git log -1 origin/master ; ";
$sGitCmd.="cd /tmp ; rm -rf \$testdir ";
$sReturn.= $this->_execAndSend($sGitCmd);
$sReturn.= shell_exec($sGitCmd);
$this->_aData["phases"]["source"] = $sReturn;
// revision aus der Ausgabe ziehen
if (preg_match ('#commit\ (.*)#', $sReturn, $aRev)){
$sRevision=$aRev[1];
}
if ($sRevision) {
$this->_aData["phases"]["source"] = array(
"revision" => $sRevision,
"message" => $sReturn
);
return $this->_aData["phases"]["source"];
}
break;
default:
die("getRepoRevision(): Build Type not supported: " . $this->_aPrjConfig["build"]["type"] . $sReturn);
......@@ -1564,10 +1577,7 @@ class project {
// echo "<pre>" . print_r($this->_aData, true) . "</pre>";
foreach (array_keys($this->_aPlaces) as $sPlace) {
$aRows[$sPlace] = $this->renderPhaseDetail($sPhase, $sPlace, $bActions, $bLong);
if ($sLastPlace && array_key_exists("version", $this->_aData["phases"][$sPhase][$sLastPlace])
&& array_key_exists("version", $this->_aData["phases"][$sPhase][$sPlace])
&& $this->_aData["phases"][$sPhase][$sLastPlace]["version"] == $this->_aData["phases"][$sPhase][$sPlace]["version"]
&& !$bLong
if ($sLastPlace && array_key_exists("version", $this->_aData["phases"][$sPhase][$sLastPlace]) && array_key_exists("version", $this->_aData["phases"][$sPhase][$sPlace]) && $this->_aData["phases"][$sPhase][$sLastPlace]["version"] == $this->_aData["phases"][$sPhase][$sPlace]["version"] && !$bLong
) {
$aRows[$sLastPlace] = $this->_renderBar($sPhase, $sPlace) . "&raquo;";
}
......@@ -1590,12 +1600,15 @@ class project {
$sKeyfile = dirname(dirname(__file__)) . "/" . $this->_aPrjConfig["build"]["keyfile"];
$sWrapper = dirname(dirname(dirname(dirname(__file__)))) . "/shellscripts/gitsshwrapper.sh";
$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 = $this->getRepoRevision();
$aRepodata = $this->getRepoRevision();
if (is_array($aRepodata) && array_key_exists("revision", $aRepodata)) {
$sRevision = $aRepodata["revision"];
$sReturn.=$this->_getChecksumDiv($sRevision);
$sReturn.= '<i class="icon-tag"></i> Revision: ' . $sRevision;
$sReturn.="<br>$sGitCmd<br>";
$sReturn.="<pre>" . $aRepodata["message"] . "</pre>";
} else {
return $this->getBox("error", "Auf das Projekt Repo konnte nicht zugegriffen werden.");
}
if (array_key_exists("webaccess", $this->_aPrjConfig["build"])) {
$sReturn.='<br>Web-GUI des Repositories:<br><a href="' . $this->_aPrjConfig["build"]["webaccess"] . '">' . $this->_aPrjConfig["build"]["webaccess"] . '</a><br>';
......@@ -1695,6 +1708,13 @@ class project {
'placeholder' => '',
);
$aRepodata = $this->getRepoRevision();
if (is_array($aRepodata) && array_key_exists("message", $aRepodata)) {
$sRepoCheck='<span class="ok">Zugriff auf das Repo erfolgreich</span><br><pre>' . $aRepodata["message"].'</pre>';
} else {
$sRepoCheck='<span class="error">FEHLER: Auf das Repo kann nicht zugegriffen werden.</span>';
$sMessages.=$this->getBox("error", "Auf das Repo kann nicht zugegriffen werden.");
}
$aForms = array(
'setup' => array(
......@@ -1800,6 +1820,14 @@ class project {
'size' => 100,
'placeholder' => '',
),
'input' . $i++ => array(
'type' => 'markup',
'value' => '<fieldset><div class="controls">'
. '<label class="control-label"> </label>'
. $sRepoCheck
. '</div></fieldset>',
),
'input' . $i++ => array(
'type' => 'text',
'name' => 'build[webaccess]',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment