From c36f82ea4e3b65a8d5a63651ca00af3c9f79cf7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Thu, 7 Nov 2013 23:48:59 -0200 Subject: [PATCH] Fixes for Per Host Configuration. --- Mage/Command/BuiltIn/DeployCommand.php | 32 ++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/Mage/Command/BuiltIn/DeployCommand.php b/Mage/Command/BuiltIn/DeployCommand.php index 81dd5f3..7340e67 100644 --- a/Mage/Command/BuiltIn/DeployCommand.php +++ b/Mage/Command/BuiltIn/DeployCommand.php @@ -226,19 +226,44 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment if (self::$deployStatus == self::SUCCEDED && $this->getConfig()->release('enabled', false) == true) { // Execute the Releases Console::output('Starting the Releaseing'); - foreach ($hosts as $host) { + foreach ($hosts as $hostKey => $host) { + + // Check if Host has specific configuration + $hostConfig = null; + if (is_array($host)) { + $hostConfig = $host; + $host = $hostKey; + } + + // Set Host $this->getConfig()->setHost($host); + $this->getConfig()->setHostConfig($hostConfig); + $task = Factory::get('deployment/release', $this->getConfig(), false, 'deploy'); if ($this->runTask($task, 'Releasing on host ' . $host . ' ... ')) { $completedTasks++; } + + // Reset Host Config + $this->getConfig()->setHostConfig(null); } Console::output('Finished the Releaseing', 1, 3); // Execute the Post-Release Tasks - foreach ($hosts as $host) { + foreach ($hosts as $hostKey => $host) { + + // Check if Host has specific configuration + $hostConfig = null; + if (is_array($host)) { + $hostConfig = $host; + $host = $hostKey; + } + + // Set Host $this->getConfig()->setHost($host); + $this->getConfig()->setHostConfig($hostConfig); + $tasksToRun = $this->getConfig()->getTasks('post-release'); $tasks = count($tasksToRun); $completedTasks = 0; @@ -261,6 +286,9 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment } Console::output('Finished Post-Release tasks for ' . $host . ': <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . ' tasks done.', 1, 3); } + + // Reset Host Config + $this->getConfig()->setHostConfig(null); } } }