|
|
@ -13,6 +13,7 @@ namespace Mage\Command\BuiltIn; |
|
|
|
use Mage\Command\AbstractCommand; |
|
|
|
use Mage\Command\AbstractCommand; |
|
|
|
use Mage\Command\RequiresEnvironment; |
|
|
|
use Mage\Command\RequiresEnvironment; |
|
|
|
use Mage\Task\Factory; |
|
|
|
use Mage\Task\Factory; |
|
|
|
|
|
|
|
use Mage\Task\AbstractTask; |
|
|
|
use Mage\Task\Releases\SkipOnOverride; |
|
|
|
use Mage\Task\Releases\SkipOnOverride; |
|
|
|
use Mage\Task\ErrorWithMessageException; |
|
|
|
use Mage\Task\ErrorWithMessageException; |
|
|
|
use Mage\Task\SkipException; |
|
|
|
use Mage\Task\SkipException; |
|
|
@ -141,7 +142,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment |
|
|
|
$this->startTime = time(); |
|
|
|
$this->startTime = time(); |
|
|
|
|
|
|
|
|
|
|
|
// Run Pre-Deployment Tasks |
|
|
|
// Run Pre-Deployment Tasks |
|
|
|
$this->runNonDeploymentTasks('pre-deploy', $this->getConfig(), 'Pre-Deployment'); |
|
|
|
$this->runNonDeploymentTasks(AbstractTask::STAGE_PRE_DEPLOY, $this->getConfig(), 'Pre-Deployment'); |
|
|
|
|
|
|
|
|
|
|
|
// Check Status |
|
|
|
// Check Status |
|
|
|
if (self::$failedTasks > 0) { |
|
|
|
if (self::$failedTasks > 0) { |
|
|
@ -159,7 +160,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Run Post-Deployment Tasks |
|
|
|
// Run Post-Deployment Tasks |
|
|
|
$this->runNonDeploymentTasks('post-deploy', $this->getConfig(), 'Post-Deployment'); |
|
|
|
$this->runNonDeploymentTasks(AbstractTask::STAGE_POST_DEPLOY, $this->getConfig(), 'Post-Deployment'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Time Information Hosts |
|
|
|
// Time Information Hosts |
|
|
@ -197,7 +198,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment |
|
|
|
self::$failedTasks = 0; |
|
|
|
self::$failedTasks = 0; |
|
|
|
|
|
|
|
|
|
|
|
// PreDeployment Hook |
|
|
|
// PreDeployment Hook |
|
|
|
if ($stage == 'pre-deploy') { |
|
|
|
if ($stage == AbstractTask::STAGE_PRE_DEPLOY) { |
|
|
|
// Look for Remote Source |
|
|
|
// Look for Remote Source |
|
|
|
if (is_array($config->deployment('source', null))) { |
|
|
|
if (is_array($config->deployment('source', null))) { |
|
|
|
array_unshift($tasksToRun, 'scm/clone'); |
|
|
|
array_unshift($tasksToRun, 'scm/clone'); |
|
|
@ -210,7 +211,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// PostDeployment Hook |
|
|
|
// PostDeployment Hook |
|
|
|
if ($stage == 'post-deploy') { |
|
|
|
if ($stage == AbstractTask::STAGE_POST_DEPLOY) { |
|
|
|
// If Deploy failed, clear post deploy tasks |
|
|
|
// If Deploy failed, clear post deploy tasks |
|
|
|
if (self::$deployStatus == self::FAILED) { |
|
|
|
if (self::$deployStatus == self::FAILED) { |
|
|
|
$tasksToRun = array(); |
|
|
|
$tasksToRun = array(); |
|
|
@ -328,7 +329,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
foreach ($tasksToRun as $taskData) { |
|
|
|
foreach ($tasksToRun as $taskData) { |
|
|
|
$tasks++; |
|
|
|
$tasks++; |
|
|
|
$task = Factory::get($taskData, $this->getConfig(), false, 'deploy'); |
|
|
|
$task = Factory::get($taskData, $this->getConfig(), false, AbstractTask::STAGE_DEPLOY); |
|
|
|
|
|
|
|
|
|
|
|
if ($this->runTask($task)) { |
|
|
|
if ($this->runTask($task)) { |
|
|
|
$completedTasks++; |
|
|
|
$completedTasks++; |
|
|
@ -374,7 +375,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment |
|
|
|
$this->getConfig()->setHost($host); |
|
|
|
$this->getConfig()->setHost($host); |
|
|
|
$this->getConfig()->setHostConfig($hostConfig); |
|
|
|
$this->getConfig()->setHostConfig($hostConfig); |
|
|
|
|
|
|
|
|
|
|
|
$task = Factory::get('deployment/release', $this->getConfig(), false, 'deploy'); |
|
|
|
$task = Factory::get('deployment/release', $this->getConfig(), false, AbstractTask::STAGE_DEPLOY); |
|
|
|
|
|
|
|
|
|
|
|
if ($this->runTask($task, 'Releasing on host <purple>' . $host . '</purple> ... ')) { |
|
|
|
if ($this->runTask($task, 'Releasing on host <purple>' . $host . '</purple> ... ')) { |
|
|
|
$completedTasks++; |
|
|
|
$completedTasks++; |
|
|
@ -399,7 +400,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment |
|
|
|
$this->getConfig()->setHost($host); |
|
|
|
$this->getConfig()->setHost($host); |
|
|
|
$this->getConfig()->setHostConfig($hostConfig); |
|
|
|
$this->getConfig()->setHostConfig($hostConfig); |
|
|
|
|
|
|
|
|
|
|
|
$tasksToRun = $this->getConfig()->getTasks('post-release'); |
|
|
|
$tasksToRun = $this->getConfig()->getTasks(AbstractTask::STAGE_POST_RELEASE); |
|
|
|
$tasks = count($tasksToRun); |
|
|
|
$tasks = count($tasksToRun); |
|
|
|
$completedTasks = 0; |
|
|
|
$completedTasks = 0; |
|
|
|
|
|
|
|
|
|
|
@ -407,7 +408,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment |
|
|
|
Console::output('Starting <dark_gray>Post-Release</dark_gray> tasks for <dark_gray>' . $host . '</dark_gray>:'); |
|
|
|
Console::output('Starting <dark_gray>Post-Release</dark_gray> tasks for <dark_gray>' . $host . '</dark_gray>:'); |
|
|
|
|
|
|
|
|
|
|
|
foreach ($tasksToRun as $task) { |
|
|
|
foreach ($tasksToRun as $task) { |
|
|
|
$task = Factory::get($task, $this->getConfig(), false, 'post-release'); |
|
|
|
$task = Factory::get($task, $this->getConfig(), false, AbstractTask::STAGE_POST_RELEASE); |
|
|
|
|
|
|
|
|
|
|
|
if ($this->runTask($task)) { |
|
|
|
if ($this->runTask($task)) { |
|
|
|
$completedTasks++; |
|
|
|
$completedTasks++; |
|
|
|