diff --git a/src/PHPCensor/Model/Build/GithubBuild.php b/src/PHPCensor/Model/Build/GithubBuild.php index 61694ee1..00dd2dc2 100644 --- a/src/PHPCensor/Model/Build/GithubBuild.php +++ b/src/PHPCensor/Model/Build/GithubBuild.php @@ -80,11 +80,11 @@ class GithubBuild extends RemoteGitBuild break; } - $url = Config::getInstance()->get('php-censor.url'); + $phpCensorUrl = Config::getInstance()->get('php-censor.url'); $params = [ 'state' => $status, - 'target_url' => $url . '/build/view/' . $this->getId(), + 'target_url' => $phpCensorUrl . '/build/view/' . $this->getId(), 'description' => $description, 'context' => 'PHP Censor', ]; @@ -163,9 +163,10 @@ class GithubBuild extends RemoteGitBuild * Handle any post-clone tasks, like applying a pull request patch on top of the branch. * @param Builder $builder * @param $cloneTo + * @param array $extra * @return bool */ - protected function postCloneSetup(Builder $builder, $cloneTo) + protected function postCloneSetup(Builder $builder, $cloneTo, array $extra = null) { $buildType = $this->getExtra('build_type'); @@ -177,6 +178,9 @@ class GithubBuild extends RemoteGitBuild $remoteBranch = $this->getExtra('remote_branch'); $cmd = 'cd "%s" && git checkout -b php-censor/' . $this->getId() . ' %s && git pull -q --no-edit %s %s'; + if (!empty($extra['git_ssh_wrapper'])) { + $cmd = 'export GIT_SSH="'.$extra['git_ssh_wrapper'].'" && ' . $cmd; + } $success = $builder->executeCommand($cmd, $cloneTo, $this->getBranch(), $remoteUrl, $remoteBranch); } } catch (\Exception $ex) { @@ -184,7 +188,7 @@ class GithubBuild extends RemoteGitBuild } if ($success) { - $success = parent::postCloneSetup($builder, $cloneTo); + $success = parent::postCloneSetup($builder, $cloneTo, $extra); } return $success; diff --git a/src/PHPCensor/Model/Build/MercurialBuild.php b/src/PHPCensor/Model/Build/MercurialBuild.php index 30fb442c..bcc8ed4a 100644 --- a/src/PHPCensor/Model/Build/MercurialBuild.php +++ b/src/PHPCensor/Model/Build/MercurialBuild.php @@ -79,9 +79,10 @@ class MercurialBuild extends Build * Handle post-clone tasks (switching branch, etc.) * @param Builder $builder * @param $cloneTo + * @param array $extra * @return bool */ - protected function postCloneSetup(Builder $builder, $cloneTo) + protected function postCloneSetup(Builder $builder, $cloneTo, array $extra = null) { $success = true; $commit = $this->getCommitId(); diff --git a/src/PHPCensor/Model/Build/RemoteGitBuild.php b/src/PHPCensor/Model/Build/RemoteGitBuild.php index 3978fe10..4486e73e 100644 --- a/src/PHPCensor/Model/Build/RemoteGitBuild.php +++ b/src/PHPCensor/Model/Build/RemoteGitBuild.php @@ -114,7 +114,11 @@ class RemoteGitBuild extends Build $success = $builder->executeCommand($cmd, $this->getBranch(), $this->getCloneUrl(), $cloneTo); if ($success) { - $success = $this->postCloneSetup($builder, $cloneTo); + $extra = [ + 'git_ssh_wrapper' => $gitSshWrapper + ]; + + $success = $this->postCloneSetup($builder, $cloneTo, $extra); } // Remove the key file and git wrapper: @@ -128,9 +132,10 @@ class RemoteGitBuild extends Build * Handle any post-clone tasks, like switching branches. * @param Builder $builder * @param $cloneTo + * @param array $extra * @return bool */ - protected function postCloneSetup(Builder $builder, $cloneTo) + protected function postCloneSetup(Builder $builder, $cloneTo, array $extra = null) { $success = true; $commit = $this->getCommitId();