diff --git a/public_html/deployment/classes/project.class.php b/public_html/deployment/classes/project.class.php index 4a859b54677f49022e69a7421d5744fd43b9f946..454cc13d46eac5dc5d3d2798a9b6cbb2a7e4d7f3 100644 --- a/public_html/deployment/classes/project.class.php +++ b/public_html/deployment/classes/project.class.php @@ -1723,12 +1723,10 @@ class project extends base $sReturn .= '<pre>' . $this->_oVcs->getSources($sTempBuildDir) . '</pre>'; - $aVersion = $this->_oVcs->getRevision($sTempBuildDir); - $sRevision = $aVersion["revision"]; - $sCommitMsg = $aVersion["message"]; - $sReturn .= $this->_oHtml->getBox("info", t('commitmessage') . '<pre>'.htmlentities($sCommitMsg).'</pre>'); - + $aRepodata=$this->getRepoRevision(); + $sRevisionShort=substr($aRepodata['revision'], 0, 8); + $sReturn .= $this->_oHtml->getBox("info", t('commitmessage') . '<pre>'.htmlentities($aRepodata['message']).'</pre>'); $sReturn .= $this->_execAndSend("ls -lisa $sTempBuildDir"); if (!$this->_iRcAll == 0) { @@ -1747,20 +1745,42 @@ class project extends base } // -------------------------------------------------- $sCfgout = $sTempBuildDir . '/ci-custom-vars'; + $sCfgContent = ''; if (isset($this->_aPrjConfig['deploy']["configfile"]) && $this->_aPrjConfig['deploy']["configfile"]) { # task#5047 - FIX EOL - $sCfgContent = $this->_aPrjConfig['deploy']["configfile"]; + $sCfgContent .= $this->_aPrjConfig['deploy']["configfile"]; // detect unix, linux, mac if (DIRECTORY_SEPARATOR === '/') { - $sCfgContent = str_replace("\r\n", "\n", $sCfgContent); + $sCfgContent .= str_replace("\r\n", "\n", $sCfgContent); } # /task#5047 - file_put_contents($sCfgout, $sCfgContent); - $sReturn .= $this->_execAndSend('ls -l ' . $sCfgout); - $sReturn .= $this->_execAndSend('cat ' . $sCfgout); } + $aCivars=[ + 'branch'=>$aRepodata['branch'], + 'branch_short'=>$aRepodata['shortname'], + 'branch_type'=>$aRepodata['type'], + 'revision'=>$aRepodata['revision'], + 'revision_short'=>$sRevisionShort, + 'imagepart'=>$aRepodata['type']=='tags' + ? $aRepodata['shortname'] + : $sRevisionShort + , + // 'message'=>$aRepodata['message'], + ]; + + $sCfgContent .= "\n" + . "# ---------- generated CI SERVER variables\n" + . "\n" + ; + foreach ($aCivars as $sKey => $value){ + $sCfgContent .= "export CI_$sKey=\"$value\"; \n"; + } + + file_put_contents($sCfgout, $sCfgContent); + $sReturn .= $this->_execAndSend('ls -l ' . $sCfgout); + $sReturn .= $this->_execAndSend('cat ' . $sCfgout); $sReturn .= $this->_oHtml->getBox("success", t('class-project-info-build-checkout-ok')); $aActionList['iActive']++; @@ -1885,10 +1905,11 @@ class project extends base return $this->_oHtml->getBox("error", $sError . $sReturn); } // $sReturn.=$this->_oHtml->getBox("success", "preparations ok - directory is ready for packaging now."); - // generate info file + + // --- generate info file $sTs = date("Y-m-d H:i:s"); $sTs2 = date("Ymd_His"); - $sBranch = ($this->_sBranchname ? $this->_sBranchname : t("defaultbranch")); + // $sBranch = ($this->_sBranchname ? $this->_sBranchname : t("defaultbranch")); $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")); @@ -1896,9 +1917,16 @@ class project extends base $aInfos = array( 'date' => $sTs, 'version' => $sTs2, - 'branch' => $sBranch, - 'revision' => $sRevision, - 'message' => $sCommitMsg, + // 'branch' => $sBranch, + 'branch'=>$aRepodata['branch'], + 'branch_short'=>$aRepodata['shortname'], + 'branch_type'=>$aRepodata['type'], + 'revision'=>$aRepodata['revision'], + 'revision_short'=>$sRevisionShort, + + 'imagepart'=>$aCivars['imagepart'], + + 'message' => $aRepodata['message'], ); /* "user": "' . $aParams["inputUser"] . '", diff --git a/public_html/deployment/classes/vcs.git.class.php b/public_html/deployment/classes/vcs.git.class.php index 8b49626fceb6fd89ab1c6a8fec00b6a9c4f12064..406aaf047fc6f4ba2bd2595ede24aa3bf962a100 100644 --- a/public_html/deployment/classes/vcs.git.class.php +++ b/public_html/deployment/classes/vcs.git.class.php @@ -297,7 +297,7 @@ class vcs implements iVcs { $aTmp = explode("\t", $sBranchLine); $sBranchPath = preg_replace('#^refs/#', '', $aTmp[1]); - $sBranch = preg_replace('#^[a-z]*\/#', '', $sBranchPath); + $sBranch = preg_replace('#^[^/]*/#', '', $sBranchPath); // skip dereferences // http://stackoverflow.com/questions/15472107/when-listing-git-ls-remote-why-theres-after-the-tag-name @@ -314,6 +314,7 @@ class vcs implements iVcs { // 'debug'=> $aTmp, 'revision' => $sRevision, 'name' => $sName, + 'shortname' => $sBranch, 'label' => $sType . ': ' . $sBranch, 'type' => $sType, // 'message' => $sMessage @@ -359,8 +360,11 @@ class vcs implements iVcs { if ($sMessage) { $aReturn = array( 'branch' => $this->_sCurrentBranch, + 'shortname' => $this->_aRemoteBranches[$this->_sCurrentBranch]['shortname'], 'revision' => $this->_aRemoteBranches[$this->_sCurrentBranch]['revision'], + 'type' => $this->_aRemoteBranches[$this->_sCurrentBranch]['type'], 'message' => $sMessage, + '_data'=>$this->_aRemoteBranches[$this->_sCurrentBranch], ); } else { $aReturn = $this->getRevision(false);