/** * Sequentially execute the stages for each node, so first all nodes will go through the initialize stage and * then the next stage will be executed until the final stage is reached and the workflow is finished. * * A rollback will be done for all nodes as long as the stage switch was not completed. * * @param Deployment $deployment * @return void * @throws \TYPO3\Surf\Exception\InvalidConfigurationException */ public function run(Deployment $deployment) { parent::run($deployment); $applications = $deployment->getApplications(); if (count($applications) === 0) { throw new InvalidConfigurationException('No application configured for deployment', 1334652420); } $nodes = $deployment->getNodes(); if (count($nodes) === 0) { throw new InvalidConfigurationException('No nodes configured for application', 1334652427); } foreach ($this->stages as $stage) { $deployment->getLogger()->notice('Stage ' . $stage); foreach ($nodes as $node) { $deployment->getLogger()->debug('Node ' . $node->getName()); foreach ($applications as $application) { if (!$application->hasNode($node)) { continue; } $deployment->getLogger()->debug('Application ' . $application->getName()); try { $this->executeStage($stage, $node, $application, $deployment); } catch (\Exception $exception) { $deployment->setStatus(Deployment::STATUS_FAILED); if ($this->enableRollback) { if (array_search($stage, $this->stages) <= array_search('switch', $this->stages)) { $deployment->getLogger()->error('Got exception "' . $exception->getMessage() . '" rolling back.'); $this->taskManager->rollback(); } else { $deployment->getLogger()->error('Got exception "' . $exception->getMessage() . '" but after switch stage, no rollback necessary.'); $this->taskManager->reset(); } } else { $deployment->getLogger()->error('Got exception "' . $exception->getMessage() . '" but rollback disabled. Stopping.'); } return; } } } } if ($deployment->getStatus() === Deployment::STATUS_UNKNOWN) { $deployment->setStatus(Deployment::STATUS_SUCCESS); } }
/** * Simulate this deployment without executing tasks * * It will set dryRun = TRUE which can be inspected by any task. * * @return void */ public function simulate() { $this->setDryRun(true); $this->logger->notice('Simulating ' . $this->name . ' (' . $this->releaseIdentifier . ')'); $this->workflow->run($this); }