diff --git a/PHPCI/Service/BuildService.php b/PHPCI/Service/BuildService.php index 117b94e7..7db8d474 100644 --- a/PHPCI/Service/BuildService.php +++ b/PHPCI/Service/BuildService.php @@ -152,6 +152,7 @@ class BuildService if (!empty($settings['host']) && !empty($settings['queue'])) { $jobData = array( + 'type' => 'phpci.build', 'build_id' => $build->getId(), ); diff --git a/PHPCI/Worker/BuildWorker.php b/PHPCI/Worker/BuildWorker.php index cc070a76..33bccd9e 100644 --- a/PHPCI/Worker/BuildWorker.php +++ b/PHPCI/Worker/BuildWorker.php @@ -82,6 +82,7 @@ class BuildWorker { $pheanstalk = new Pheanstalk($this->host); $pheanstalk->watch($this->queue); + $pheanstalk->ignore('default'); $buildStore = Factory::getStore('Build'); $jobs = 0; @@ -99,6 +100,19 @@ class BuildWorker // Get the job data and run the job: $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'); // If the job comes with config data, reset our config and database connections