mirror of https://github.com/hauke68/Magallanes
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.9 KiB
71 lines
1.9 KiB
13 years ago
|
<?php
|
||
|
class Mage_Task_Releases
|
||
|
{
|
||
|
private $_config = null;
|
||
|
private $_action = null;
|
||
13 years ago
|
private $_release = null;
|
||
13 years ago
|
|
||
13 years ago
|
public function setAction($action)
|
||
|
{
|
||
|
$this->_action = $action;
|
||
|
return $this;
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
public function getAction()
|
||
|
{
|
||
|
return $this->_action;
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
public function setRelease($releaseId)
|
||
|
{
|
||
|
$this->_release = $releaseId;
|
||
|
return $this;
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
public function getRelease()
|
||
|
{
|
||
|
return $this->_release;
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
public function run(Mage_Config $config)
|
||
|
{
|
||
|
$this->_config = $config;
|
||
13 years ago
|
|
||
13 years ago
|
if ($config->getEnvironmentName() == '') {
|
||
13 years ago
|
Mage_Console::output('<red>You must specify an environment</red>', 0, 2);
|
||
|
return;
|
||
13 years ago
|
}
|
||
|
|
||
|
$lockFile = '.mage/' . $config->getEnvironmentName() . '.lock';
|
||
|
if (file_exists($lockFile)) {
|
||
|
Mage_Console::output('<red>This environment is locked!</red>', 0, 2);
|
||
|
return;
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
// Run Tasks for Deployment
|
||
|
$hosts = $config->getHosts();
|
||
13 years ago
|
|
||
13 years ago
|
if (count($hosts) == 0) {
|
||
|
Mage_Console::output('<light_purple>Warning!</light_purple> <dark_gray>No hosts defined, unable to get releases.</dark_gray>', 1, 3);
|
||
13 years ago
|
|
||
13 years ago
|
} else {
|
||
|
foreach ($hosts as $host) {
|
||
13 years ago
|
$config->setHost($host);
|
||
13 years ago
|
switch ($this->getAction()) {
|
||
|
case 'list':
|
||
13 years ago
|
$task = Mage_Task_Factory::get('releases/list', $config);
|
||
13 years ago
|
$task->init();
|
||
|
$result = $task->run();
|
||
|
break;
|
||
13 years ago
|
|
||
13 years ago
|
case 'rollback':
|
||
|
$task = Mage_Task_Factory::get('releases/rollback', $config);
|
||
|
$task->init();
|
||
|
$task->setRelease($this->getRelease());
|
||
|
$result = $task->run();
|
||
|
break;
|
||
13 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|