|
|
|
@ -28,44 +28,51 @@ class ReleasesCommand extends AbstractCommand implements RequiresEnvironment
|
|
|
|
|
*/ |
|
|
|
|
public function run() |
|
|
|
|
{ |
|
|
|
|
if (!is_numeric($this->getConfig()->getParameter('release', ''))) { |
|
|
|
|
Console::output('<red>This release is mandatory.</red>', 1, 2); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$subcommand = $this->getConfig()->getArgument(1); |
|
|
|
|
$lockFile = getcwd() . '/.mage/' . $this->getConfig()->getEnvironment() . '.lock'; |
|
|
|
|
if (file_exists($lockFile) && ($subcommand == 'rollback')) { |
|
|
|
|
Console::output('<red>This environment is locked!</red>', 1, 2); |
|
|
|
|
echo file_get_contents($lockFile); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
$subCommand = $this->getConfig()->getArgument(1); |
|
|
|
|
|
|
|
|
|
// Run Tasks for Deployment |
|
|
|
|
$hosts = $this->getConfig()->getHosts(); |
|
|
|
|
|
|
|
|
|
if (count($hosts) == 0) { |
|
|
|
|
Console::output('<light_purple>Warning!</light_purple> <dark_gray>No hosts defined, unable to get releases.</dark_gray>', 1, 3); |
|
|
|
|
Console::output( |
|
|
|
|
'<light_purple>Warning!</light_purple> <dark_gray>No hosts defined, unable to get releases.</dark_gray>', |
|
|
|
|
1, 3 |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach ($hosts as $host) { |
|
|
|
|
$this->getConfig()->setHost($host); |
|
|
|
|
|
|
|
|
|
switch ($subCommand) { |
|
|
|
|
case 'list': |
|
|
|
|
$task = Factory::get('releases/list', $this->getConfig()); |
|
|
|
|
$task->init(); |
|
|
|
|
$result = $task->run(); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
foreach ($hosts as $host) { |
|
|
|
|
$this->getConfig()->setHost($host); |
|
|
|
|
case 'rollback': |
|
|
|
|
if (!is_numeric($this->getConfig()->getParameter('release', ''))) { |
|
|
|
|
Console::output('<red>Missing required releaseid.</red>', 1, 2); |
|
|
|
|
|
|
|
|
|
switch ($subcommand) { |
|
|
|
|
case 'list': |
|
|
|
|
$task = Factory::get('releases/list', $this->getConfig()); |
|
|
|
|
$task->init(); |
|
|
|
|
$result = $task->run(); |
|
|
|
|
break; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$lockFile = getcwd() . '/.mage/' . $this->getConfig()->getEnvironment() . '.lock'; |
|
|
|
|
if (file_exists($lockFile)) { |
|
|
|
|
Console::output('<red>This environment is locked!</red>', 1, 2); |
|
|
|
|
echo file_get_contents($lockFile); |
|
|
|
|
|
|
|
|
|
case 'rollback': |
|
|
|
|
$releaseId = $this->getConfig()->getParameter('release', ''); |
|
|
|
|
$task = Factory::get('releases/rollback', $this->getConfig()); |
|
|
|
|
$task->init(); |
|
|
|
|
$task->setRelease($releaseId); |
|
|
|
|
$result = $task->run(); |
|
|
|
|
break; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$releaseId = $this->getConfig()->getParameter('release', ''); |
|
|
|
|
$task = Factory::get('releases/rollback', $this->getConfig()); |
|
|
|
|
$task->init(); |
|
|
|
|
$task->setRelease($releaseId); |
|
|
|
|
$result = $task->run(); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|