Browse Source

Issue #46 - Add post-release tasks on rollback

1.0
Andrés Montañez 11 years ago
parent
commit
5d03d945cb
  1. 23
      Mage/Task/BuiltIn/Releases/RollbackTask.php
  2. 6
      docs/example-config/.mage/config/environment/staging.yml

23
Mage/Task/BuiltIn/Releases/RollbackTask.php

@ -109,6 +109,7 @@ class RollbackTask extends AbstractTask implements IsReleaseAware
$tasksToRun = $this->getConfig()->getTasks(); $tasksToRun = $this->getConfig()->getTasks();
$this->getConfig()->setReleaseId($releaseId); $this->getConfig()->setReleaseId($releaseId);
// Run Deploy Tasks
foreach ($tasksToRun as $taskData) { foreach ($tasksToRun as $taskData) {
$task = Factory::get($taskData, $this->getConfig(), true, self::STAGE_DEPLOY); $task = Factory::get($taskData, $this->getConfig(), true, self::STAGE_DEPLOY);
$task->init(); $task->init();
@ -151,6 +152,28 @@ class RollbackTask extends AbstractTask implements IsReleaseAware
Console::output('<red>FAIL</red>', 0); Console::output('<red>FAIL</red>', 0);
} }
// Run Post Release Tasks
$tasksToRun = $this->getConfig()->getTasks(AbstractTask::STAGE_POST_DEPLOY);
foreach ($tasksToRun as $taskData) {
$task = Factory::get($taskData, $this->getConfig(), true, self::STAGE_POST_DEPLOY);
$task->init();
Console::output('Running <purple>' . $task->getName() . '</purple> ... ', 2, false);
if ($task instanceOf RollbackAware) {
$tasks++;
$result = $task->run();
if ($result == true) {
Console::output('<green>OK</green>', 0);
$completedTasks++;
} else {
Console::output('<red>FAIL</red>', 0);
}
} else {
Console::output('<yellow>SKIPPED</yellow>', 0);
}
}
if ($completedTasks == $tasks) { if ($completedTasks == $tasks) {
$tasksColor = 'green'; $tasksColor = 'green';
} else { } else {

6
docs/example-config/.mage/config/environment/staging.yml

@ -12,15 +12,15 @@ releases:
directory: releases directory: releases
hosts: hosts:
- localhost - localhost
# - dbserver - 127.0.0.1
tasks: tasks:
pre-deploy: pre-deploy:
- sampleTask # - sampleTask
# - failTask # - failTask
- scm/update - scm/update
on-deploy: on-deploy:
- privileges - privileges
- sampleTask # - sampleTask
- sampleTaskRollbackAware - sampleTaskRollbackAware
- taskWithParameters: - taskWithParameters:
booleanOption: true booleanOption: true

Loading…
Cancel
Save