From f11a4e7d703ee3278108da0c719a651d2e16acc6 Mon Sep 17 00:00:00 2001 From: hahn <axel.hahn@iml.unibe.ch> Date: Mon, 11 Dec 2017 12:15:55 +0100 Subject: [PATCH] task#1726 - add environment before executing hooks --- public_html/deployment/classes/project.class.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/public_html/deployment/classes/project.class.php b/public_html/deployment/classes/project.class.php index 0b032dda..082abffd 100644 --- a/public_html/deployment/classes/project.class.php +++ b/public_html/deployment/classes/project.class.php @@ -1604,12 +1604,21 @@ class project extends base { // -------------------------------------------------- // execute hook postclone // -------------------------------------------------- + // task#1726 - add environment + $sSetEnv='' + . 'export GIT_SSH="'.$this->_aConfig['appRootDir'].'shellscripts/gitsshwrapper.sh";' + . 'export DIR_SSH_KEYS="'.$this->_aConfig['dataDir'].'/sshkeys";' + . 'export DIR_APPROOT="'.$sTempDir.'";' + ; + $sHookfile = $this->_aConfig['hooks']['build-postclone']; - $sReturn.='<h3>' . t('class-project-build-label-execute-hook-postclone') . ' (' . $sHookfile . ')</h3>'; + $sReturn.='<h3>' . t('class-project-build-label-execute-hook-postclone') . ' (' . $sHookfile . ')</h3>' + . 'env: <pre>'.$sSetEnv.'</pre>'; + if (file_exists($sTempDir . '/' . $sHookfile)) { // $sReturn.=$this->_execAndSend('chmod 755 ' . $sTempDir . '/hooks/on*'); // $this->_iRcAll = 0; - $sReturn.=$this->_execAndSend('bash --login -c \'' . $sTempDir . '/' . $sHookfile . '\''); + $sReturn.=$this->_execAndSend('bash --login -c \'' . $sSetEnv.' '.$sTempDir . '/' . $sHookfile . '\''); if (!$this->_iRcAll == 0) { $sError = sprintf(t('class-project-error-command-failed'), $sTempDir); $this->_logaction($sError, __FUNCTION__, "error"); @@ -1645,7 +1654,7 @@ class project extends base { if (file_exists($sTempDir . '/' . $sHookfile)) { // $sReturn.=$this->_execAndSend('chmod 755 ' . $sTempDir . '/hooks/on*'); // $this->_iRcAll = 0; - $sReturn.=$this->_execAndSend('bash --login -c \'' . $sTempDir . '/' . $sHookfile . '\''); + $sReturn.=$this->_execAndSend('bash --login -c \'' . $sSetEnv.' '.$sTempDir . '/' . $sHookfile . '\''); if (!$this->_iRcAll == 0) { $this->_TempDelete(); $sError = sprintf(t('class-project-error-command-failed'), $sTempDir) . $sReturn; -- GitLab