*/ class GitController extends \PHPCI\Controller { public function init() { $this->_buildStore = Store\Factory::getStore('Build'); } /** * Called by POSTing to /git/webhook/?branch=&commit= * * @param string $project */ public function webhook($project) { $branch = $this->getParam('branch'); $commit = $this->getParam('commit'); try { $build = new Build(); $build->setProjectId($project); if ($branch !== null && trim($branch) !== '') { $build->setBranch($branch); } else { $build->setBranch('master'); } if ($commit !== null && trim($commit) !== '') { $build->setCommitId($commit); } $build->setStatus(0); $build->setLog(''); $build->setCreated(new \DateTime()); } catch (\Exception $ex) { header('HTTP/1.1 400 Bad Request'); header('Ex: ' . $ex->getMessage()); die('FAIL'); } try { $this->_buildStore->save($build); } catch (\Exception $ex) { header('HTTP/1.1 500 Internal Server Error'); header('Ex: ' . $ex->getMessage()); die('FAIL'); } die('OK'); } }