Example #1
0
 /**
  * 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
  */
 public function run(Deployment $deployment)
 {
     parent::run($deployment);
     $nodes = $deployment->getNodes();
     foreach ($this->stages as $stage) {
         $deployment->getLogger()->log('====== Stage ' . $stage . ' ======', LOG_DEBUG);
         foreach ($nodes as $node) {
             $deployment->getLogger()->log('**** Node ' . $node->getName() . ' ****', LOG_DEBUG);
             foreach ($deployment->getApplications() as $application) {
                 if (!$application->hasNode($node)) {
                     continue;
                 }
                 $deployment->getLogger()->log('* Application ' . $application->getName() . ' *', LOG_DEBUG);
                 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()->log('Got exception "' . $exception->getMessage() . '" rolling back.', LOG_ERR);
                             $this->taskManager->rollback();
                         } else {
                             $deployment->getLogger()->log('Got exception "' . $exception->getMessage() . '" but after switch stage, no rollback necessary.', LOG_ERR);
                             $this->taskManager->reset();
                         }
                     } else {
                         $deployment->getLogger()->log('Got exception "' . $exception->getMessage() . '" but rollback disabled. Stopping.', LOG_ERR);
                     }
                     return;
                 }
             }
         }
     }
     if ($deployment->getStatus() === Deployment::STATUS_UNKNOWN) {
         $deployment->setStatus(Deployment::STATUS_SUCCESS);
     }
 }
 /**
  * Configure tasks
  *
  * @param Workflow $workflow
  * @param Deployment $deployment
  */
 protected function defineTasks(Workflow $workflow, Deployment $deployment)
 {
     $excludePatterns = array('.git*', 'Data/*', 'Web/_Resources/*', 'Build/Reports', './Cache', 'Configuration/PackageStates.php');
     $baseArchiveConfiguration = array('sourceDirectory' => $deployment->getApplicationReleasePath($this), 'baseDirectory' => $this->configuration['versionAndProjectName'], 'exclude' => $excludePatterns);
     $workflow->defineTask('createZipDistribution', 'typo3.deploy:createArchive', array_merge($baseArchiveConfiguration, array('targetFile' => $this->configuration['zipFile'])));
     $workflow->defineTask('createTarGzDistribution', 'typo3.deploy:createArchive', array_merge($baseArchiveConfiguration, array('targetFile' => $this->configuration['tarGzFile'])));
     $workflow->defineTask('createTarBz2Distribution', 'typo3.deploy:createArchive', array_merge($baseArchiveConfiguration, array('targetFile' => $this->configuration['tarBz2File'])));
     if ($this->hasOption('enableSourceforgeUpload') && $this->getOption('enableSourceforgeUpload') === TRUE) {
         $workflow->defineTask('typo3.deploy:sourceforgeupload', 'typo3.deploy:sourceforgeupload', array('sourceforgeProjectName' => $this->getOption('sourceforgeProjectName'), 'sourceforgePackageName' => $this->getOption('sourceforgePackageName'), 'sourceforgeUserName' => $this->getOption('sourceforgeUserName'), 'version' => $this->getOption('version'), 'files' => array($this->configuration['zipFile'], $this->configuration['tarGzFile'], $this->configuration['tarBz2File'])));
     }
     $workflow->defineTask('typo3.deploy:git:tag', 'typo3.deploy:git:tag', array('tagName' => $this->getOption('version'), 'description' => 'Tag distribution with tag ' . $this->getOption('version')));
 }
Example #3
0
 /**
  * Simulate this deployment without executing tasks
  *
  * @return void
  */
 public function simulate()
 {
     $this->setDryRun(TRUE);
     $this->logger->log('Simulating ' . $this->name);
     $this->workflow->run($this);
 }