コード例 #1
0
ファイル: Builder.php プロジェクト: bdanchilla/PHPCI
 /**
  * Run the active build.
  */
 public function execute()
 {
     // Update the build in the database, ping any external services.
     $this->build->setStatus(Build::STATUS_RUNNING);
     $this->build->setStarted(new \DateTime());
     $this->store->save($this->build);
     $this->build->sendStatusPostback();
     $success = true;
     $previous_build = $this->build->getProject()->getPreviousBuild($this->build->getBranch());
     $previous_state = Build::STATUS_NEW;
     if ($previous_build) {
         $previous_state = $previous_build->getStatus();
     }
     try {
         // Set up the build:
         $this->setupBuild();
         // Run the core plugin stages:
         foreach (array('setup', 'test') as $stage) {
             $success &= $this->pluginExecutor->executePlugins($this->config, $stage);
         }
         // Set the status so this can be used by complete, success and failure
         // stages.
         if ($success) {
             $this->build->setStatus(Build::STATUS_SUCCESS);
         } else {
             $this->build->setStatus(Build::STATUS_FAILED);
         }
         if ($success) {
             $this->pluginExecutor->executePlugins($this->config, 'success');
             if ($previous_state == Build::STATUS_FAILED) {
                 $this->pluginExecutor->executePlugins($this->config, 'fixed');
             }
             $this->buildLogger->logSuccess(Lang::get('build_success'));
         } else {
             $this->pluginExecutor->executePlugins($this->config, 'failure');
             if ($previous_state == Build::STATUS_SUCCESS || $previous_state == Build::STATUS_NEW) {
                 $this->pluginExecutor->executePlugins($this->config, 'broken');
             }
             $this->buildLogger->logFailure(Lang::get('build_failed'));
         }
     } catch (\Exception $ex) {
         $this->build->setStatus(Build::STATUS_FAILED);
         $this->buildLogger->logFailure(Lang::get('exception') . $ex->getMessage());
     } finally {
         // Complete stage plugins are always run
         $this->pluginExecutor->executePlugins($this->config, 'complete');
     }
     // Update the build in the database, ping any external services, etc.
     $this->build->sendStatusPostback();
     $this->build->setFinished(new \DateTime());
     // Clean up:
     $this->buildLogger->log(Lang::get('removing_build'));
     $this->build->removeBuildDirectory();
     $this->store->save($this->build);
 }
コード例 #2
0
ファイル: ExecutorTest.php プロジェクト: mrudtf/PHPCI
 public function testExecutePlugins_CallsEachPluginForStage()
 {
     $phpUnitPluginOptions = array();
     $behatPluginOptions = array();
     $config = array('stageOne' => array('PhpUnit' => $phpUnitPluginOptions, 'Behat' => $behatPluginOptions));
     $pluginNamespace = 'PHPCI\\Plugin\\';
     $mockPhpUnitPlugin = $this->prophesize('PHPCI\\Plugin');
     $mockPhpUnitPlugin->execute()->shouldBeCalledTimes(1)->willReturn(true);
     $this->mockFactory->buildPlugin($pluginNamespace . 'PhpUnit', $phpUnitPluginOptions)->willReturn($mockPhpUnitPlugin->reveal());
     $mockBehatPlugin = $this->prophesize('PHPCI\\Plugin');
     $mockBehatPlugin->execute()->shouldBeCalledTimes(1)->willReturn(true);
     $this->mockFactory->buildPlugin($pluginNamespace . 'Behat', $behatPluginOptions)->willReturn($mockBehatPlugin->reveal());
     $this->testedExecutor->executePlugins($config, 'stageOne');
 }
コード例 #3
0
ファイル: Builder.php プロジェクト: stefanius/phpci-box
 /**
  * Run the active build.
  */
 public function execute()
 {
     // Update the build in the database, ping any external services.
     $this->build->setStatus(Build::STATUS_RUNNING);
     $this->build->setStarted(new \DateTime());
     $this->store->save($this->build);
     $this->build->sendStatusPostback();
     $success = true;
     try {
         // Set up the build:
         $this->setupBuild();
         // Run the core plugin stages:
         foreach (array('setup', 'test') as $stage) {
             $success &= $this->pluginExecutor->executePlugins($this->config, $stage);
         }
         // Set the status so this can be used by complete, success and failure
         // stages.
         if ($success) {
             $this->build->setStatus(Build::STATUS_SUCCESS);
         } else {
             $this->build->setStatus(Build::STATUS_FAILED);
         }
         // Complete stage plugins are always run
         $this->pluginExecutor->executePlugins($this->config, 'complete');
         if ($success) {
             $this->pluginExecutor->executePlugins($this->config, 'success');
             $this->buildLogger->logSuccess(Lang::get('build_success'));
         } else {
             $this->pluginExecutor->executePlugins($this->config, 'failure');
             $this->buildLogger->logFailure(Lang::get('build_failed'));
         }
         // Clean up:
         $this->buildLogger->log(Lang::get('removing_build'));
         $cmd = 'rm -Rf "%s"';
         if (IS_WIN) {
             $cmd = 'rmdir /S /Q "%s"';
         }
         $this->executeCommand($cmd, $this->buildPath);
     } catch (\Exception $ex) {
         $this->build->setStatus(Build::STATUS_FAILED);
         $this->buildLogger->logFailure(Lang::get('exception') . $ex->getMessage());
     }
     // Update the build in the database, ping any external services, etc.
     $this->build->sendStatusPostback();
     $this->build->setFinished(new \DateTime());
     $this->store->save($this->build);
 }