Inheritance: implements Deployer\Executor\ExecutorInterface
コード例 #1
0
ファイル: SeriesExecutorTest.php プロジェクト: irfan/deployer
 public function testSeriesExecutor()
 {
     $this->initialize();
     $mock = $this->getMockBuilder('stdClass')->setMethods(['task', 'once', 'only', 'onlyStaging'])->getMock();
     $mock->expects($this->exactly(2))->method('task');
     $mock->expects($this->once())->method('once');
     $mock->expects($this->once())->method('only');
     $mock->expects($this->once())->method('onlyStaging');
     $task = new Task('task', function () use($mock) {
         $mock->task();
     });
     $taskOne = new Task('once', function () use($mock) {
         $mock->once();
     });
     $taskOne->once();
     $taskOnly = new Task('only', function () use($mock) {
         $mock->only();
     });
     $taskOnly->onlyOn(['one']);
     $taskOnlyStaging = new Task('onlyStaging', function () use($mock) {
         $mock->onlyStaging();
     });
     $taskOnlyStaging->onlyForStage('staging');
     $tasks = [$task, $taskOne, $taskOnly, $taskOnlyStaging];
     $environments = ['one' => new Environment(), 'two' => new Environment()];
     $environments['two']->set('stages', ['staging']);
     $servers = ['one' => new Local(), 'two' => new Local()];
     $executor = new SeriesExecutor();
     $executor->run($tasks, $servers, $environments, $this->input, $this->output);
 }
コード例 #2
0
ファイル: TaskCommand.php プロジェクト: elfet/deployer
 /**
  * {@inheritdoc}
  */
 protected function execute(Input $input, Output $output)
 {
     $stage = $input->hasArgument('stage') ? $input->getArgument('stage') : null;
     $tasks = $this->deployer->getScriptManager()->getTasks($this->getName(), $stage);
     $servers = $this->deployer->getStageStrategy()->getServers($stage);
     $environments = iterator_to_array($this->deployer->environments);
     if (isset($this->executor)) {
         $executor = $this->executor;
     } else {
         if ($input->getOption('parallel')) {
             $executor = new ParallelExecutor($this->deployer->getConsole()->getUserDefinition());
         } else {
             $executor = new SeriesExecutor();
         }
     }
     try {
         $executor->run($tasks, $servers, $environments, $input, $output);
     } catch (\Exception $exception) {
         \Deployer\logger($exception->getMessage(), Logger::ERROR);
         // Check if we have tasks to execute on failure.
         if ($this->deployer['onFailure']->has($this->getName())) {
             $taskName = $this->deployer['onFailure']->get($this->getName());
             $tasks = $this->deployer->getScriptManager()->getTasks($taskName, $stage);
             $executor->run($tasks, $servers, $environments, $input, $output);
         }
         throw $exception;
     }
     if (Deployer::hasDefault('terminate_message')) {
         $output->writeln(Deployer::getDefault('terminate_message'));
     }
 }
コード例 #3
0
ファイル: TaskCommand.php プロジェクト: onedal88/deployer
 /**
  * {@inheritdoc}
  */
 protected function execute(Input $input, Output $output)
 {
     $tasks = [];
     foreach ($this->deployer->scenarios->get($this->getName())->getTasks() as $taskName) {
         $tasks[] = $this->deployer->tasks->get($taskName);
     }
     $stage = $input->hasArgument('stage') ? $input->getArgument('stage') : null;
     $servers = $this->deployer->getStageStrategy()->getServers($stage);
     $environments = iterator_to_array($this->deployer->environments);
     if (isset($this->executor)) {
         $executor = $this->executor;
     } else {
         if ($input->getOption('parallel')) {
             $executor = new ParallelExecutor($this->deployer->getConsole()->getUserDefinition());
         } else {
             $executor = new SeriesExecutor();
         }
     }
     $executor->run($tasks, $servers, $environments, $input, $output);
 }