protected function runRollbackTask(AbstractTask $task) { $this->getConfig()->reload(); $hosts = $this->getConfig()->getHosts(); Console::output("", 1, 2); Console::output("Starting the <bold>rollback</bold>", 1, 1); if (!in_array($task->getStage(), $this->acceptedStagesToRollback)) { $stagesString = implode(', ', $this->acceptedStagesToRollback); Console::output("<light_purple>Warning!</light_purple> <bold>Rollback during deployment can be called only at the stages: {$stagesString} <bold>", 1); Console::output("<bold>Rollback:<bold> <red>ABORTING</red>", 1, 3); } elseif (count($hosts) == 0) { Console::output('<light_purple>Warning!</light_purple> <bold>No hosts defined, unable to get releases.</bold>', 1, 3); } else { $result = true; foreach ($hosts as $hostKey => $host) { $hostConfig = null; if (is_array($host)) { $hostConfig = $host; $host = $hostKey; } // Set Host and Host Specific Config $this->getConfig()->setHost($host); $this->getConfig()->setHostConfig($hostConfig); $this->getConfig()->setReleaseId(-1); $task = Factory::get(array('name' => 'releases/rollback', 'parameters' => array('inDeploy' => true)), $this->getConfig(), false, $task->getStage()); $task->init(); $result = $task->run() && $result; } return $result; } return false; }