Verify that jobs actually come from PHPCI
This commit is contained in:
parent
de1c058f83
commit
7e2fee9504
|
@ -152,6 +152,7 @@ class BuildService
|
||||||
|
|
||||||
if (!empty($settings['host']) && !empty($settings['queue'])) {
|
if (!empty($settings['host']) && !empty($settings['queue'])) {
|
||||||
$jobData = array(
|
$jobData = array(
|
||||||
|
'type' => 'phpci.build',
|
||||||
'build_id' => $build->getId(),
|
'build_id' => $build->getId(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ class BuildWorker
|
||||||
{
|
{
|
||||||
$pheanstalk = new Pheanstalk($this->host);
|
$pheanstalk = new Pheanstalk($this->host);
|
||||||
$pheanstalk->watch($this->queue);
|
$pheanstalk->watch($this->queue);
|
||||||
|
$pheanstalk->ignore('default');
|
||||||
$buildStore = Factory::getStore('Build');
|
$buildStore = Factory::getStore('Build');
|
||||||
|
|
||||||
$jobs = 0;
|
$jobs = 0;
|
||||||
|
@ -99,6 +100,19 @@ class BuildWorker
|
||||||
|
|
||||||
// Get the job data and run the job:
|
// Get the job data and run the job:
|
||||||
$jobData = json_decode($job->getData(), true);
|
$jobData = json_decode($job->getData(), true);
|
||||||
|
|
||||||
|
if (empty($jobData) || !is_array($jobData)) {
|
||||||
|
// Probably not from PHPCI.
|
||||||
|
$pheanstalk->release($job);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!array_key_exists('type', $jobData) || $jobData['type'] !== 'phpci.build') {
|
||||||
|
// Probably not from PHPCI.
|
||||||
|
$pheanstalk->release($job);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$this->logger->addInfo('Received build #'.$jobData['build_id'].' from Beanstalkd');
|
$this->logger->addInfo('Received build #'.$jobData['build_id'].' from Beanstalkd');
|
||||||
|
|
||||||
// If the job comes with config data, reset our config and database connections
|
// If the job comes with config data, reset our config and database connections
|
||||||
|
|
Loading…
Reference in a new issue