Update GithubBuild to allow for testing pull requests, hopefully
This commit is contained in:
parent
a8868f2ab2
commit
1696e503b8
2 changed files with 45 additions and 12 deletions
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
namespace PHPCI\Model\Build;
|
||||
|
||||
use PHPCI\Builder;
|
||||
use PHPCI\Model\Build\RemoteGitBuild;
|
||||
|
||||
/**
|
||||
|
|
@ -115,4 +116,29 @@ class GithubBuild extends RemoteGitBuild
|
|||
|
||||
return $link;
|
||||
}
|
||||
|
||||
protected function postCloneSetup(Builder $builder, $cloneTo)
|
||||
{
|
||||
$buildType = $this->getExtra('build_type');
|
||||
|
||||
$success = true;
|
||||
|
||||
try {
|
||||
if (!empty($buildType) && $buildType == 'pull_request') {
|
||||
$remoteUrl = $this->getExtra('remote_url');
|
||||
$remoteBranch = $this->getExtra('remote_branch');
|
||||
|
||||
$cmd = 'cd "%s" && git checkout -b phpci/' . $this->getId() . ' %s && git pull %s %s';
|
||||
$success = $builder->executeCommand($cmd, $cloneTo, $this->getBranch(), $remoteUrl, $remoteBranch);
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
$success = false;
|
||||
}
|
||||
|
||||
if ($success) {
|
||||
$success = parent::postCloneSetup($builder, $cloneTo);
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue