Fixes for live

This commit is contained in:
Dan Cryer 2013-05-03 16:33:27 +01:00
parent 2c860e8009
commit dd59bff838
2 changed files with 29 additions and 9 deletions

View file

@ -149,6 +149,7 @@ class Builder
mkdir($this->buildPath, 0777, true);
file_put_contents($keyFile, $key);
chmod($keyFile, 0600);
$this->executeCommand('ssh-agent ssh-add '.$keyFile.' && git clone -b ' .$this->build->getBranch() . ' ' .$url.' '.$this->buildPath.' && ssh-agent -k');
unlink($keyFile);

View file

@ -13,18 +13,37 @@ class GithubController extends b8\Controller
$this->_buildStore = Store\Factory::getStore('Build');
}
public function index()
public function webhook($project)
{
$payload = json_decode($this->getParam('payload'));
$payload = json_decode($this->getParam('payload'), true);
$build = new Build();
$build->setProjectId($this->getParam('project'));
$build->setCommitId($payload['after']);
$build->setStatus(0);
$build->setLog('');
$build->setBranch(str_replace('refs/heads/', '', $payload['ref']));
try
{
$build = new Build();
$build->setProjectId($project);
$build->setCommitId($payload['after']);
$build->setStatus(0);
$build->setLog('');
$build->setBranch(str_replace('refs/heads/', '', $payload['ref']));
}
catch(\Exception $ex)
{
header('HTTP/1.1 400 Bad Request');
header('Ex: ' . $ex->getMessage());
die('FAIL');
}
$this->_buildStore->save($build);
try
{
$this->_buildStore->save($build);
}
catch(\Exception $ex)
{
header('HTTP/1.1 500 Internal Server Error');
header('Ex: ' . $ex->getMessage());
die('FAIL');
}
die('OK');
}
}