mirror of
https://github.com/hauke68/Magallanes.git
synced 2025-08-25 21:00:18 +02:00
New feature: Override Release.
This commit is contained in:
parent
aaa65800d0
commit
0410c0efec
@ -12,7 +12,12 @@ class Mage_Config
|
||||
{
|
||||
if (($environment != '') && file_exists('.mage/config/environment/' . $environment . '.yml')) {
|
||||
$this->_environment = spyc_load_file('.mage/config/environment/' . $environment . '.yml');
|
||||
$this->_environmentName = $environment;
|
||||
$this->_environmentName = $environment;
|
||||
if (is_array($this->_environment['deployment']['source'])) {
|
||||
$newTemporal = $this->_environment['deployment']['source']['temporal']
|
||||
. md5(microtime()) . '/';
|
||||
$this->_environment['deployment']['source']['temporal'] = $newTemporal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,7 +162,7 @@ class Mage_Config
|
||||
|
||||
public function setFrom($from)
|
||||
{
|
||||
$options['deployment']['from'] = $from;
|
||||
$this->_environment['deployment']['from'] = $from;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
class Mage_Console
|
||||
{
|
||||
private $_args = null;
|
||||
private $_args = array();
|
||||
private $_action = null;
|
||||
private $_actionOptions = null;
|
||||
private static $_actionOptions = array();
|
||||
private $_environment = null;
|
||||
private static $_log = null;
|
||||
private static $_logEnabled = true;
|
||||
@ -50,6 +50,14 @@ class Mage_Console
|
||||
foreach ($this->_args as $argument) {
|
||||
if (preg_match('/to:[\w]+/i', $argument)) {
|
||||
$this->_environment = str_replace('to:', '', $argument);
|
||||
|
||||
} else if (preg_match('/--[\w]+/i', $argument)) {
|
||||
$optionValue = explode('=', substr($argument, 2));
|
||||
if (count($optionValue) == 1) {
|
||||
self::$_actionOptions[$optionValue[0]] = true;
|
||||
} else if (count($optionValue) == 2) {
|
||||
self::$_actionOptions[$optionValue[0]] = $optionValue[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -64,6 +72,15 @@ class Mage_Console
|
||||
return $this->_environment;
|
||||
}
|
||||
|
||||
public static function getActionOption($name, $default = false)
|
||||
{
|
||||
if (isset(self::$_actionOptions[$name])) {
|
||||
return self::$_actionOptions[$name];
|
||||
} else {
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
|
||||
public static function output($message, $tabs = 1, $newLine = 1)
|
||||
{
|
||||
self::log(strip_tags($message));
|
||||
|
@ -10,7 +10,7 @@ class Mage_Task_BuiltIn_Deployment_Releases
|
||||
|
||||
public function run()
|
||||
{
|
||||
if ($this->_config->release('enabled', false) == true) {
|
||||
if ($this->_config->release('enabled', false) == true) {
|
||||
$releasesDirectory = $this->_config->release('directory', 'releases');
|
||||
$symlink = $this->_config->release('symlink', 'current');
|
||||
|
||||
|
@ -6,7 +6,11 @@ class Mage_Task_BuiltIn_Deployment_Rsync
|
||||
public function getName()
|
||||
{
|
||||
if ($this->_config->release('enabled', false) == true) {
|
||||
return 'Rsync (with Releases) [built-in]';
|
||||
if ($this->getActionOption('overrideRelease', false) == true) {
|
||||
return 'Rsync (with Releases override) [built-in]';
|
||||
} else {
|
||||
return 'Rsync (with Releases) [built-in]';
|
||||
}
|
||||
} else {
|
||||
return 'Rsync [built-in]';
|
||||
}
|
||||
@ -14,6 +18,16 @@ class Mage_Task_BuiltIn_Deployment_Rsync
|
||||
|
||||
public function run()
|
||||
{
|
||||
$overrideRelease = $this->getActionOption('overrideRelease', false);
|
||||
|
||||
if ($overrideRelease == true) {
|
||||
$releaseToOverride = false;
|
||||
$resultFetch = $this->_runRemoteCommand('ls -ld current | cut -d\"/\" -f2', $releaseToOverride);
|
||||
if (is_numeric($releaseToOverride)) {
|
||||
$this->_config->setReleaseId($releaseToOverride);
|
||||
}
|
||||
}
|
||||
|
||||
$excludes = array(
|
||||
'.git',
|
||||
'.svn',
|
||||
|
@ -99,15 +99,13 @@ class Mage_Task_Deploy
|
||||
{
|
||||
$tasksToRun = $config->getTasks($stage);
|
||||
|
||||
// Look for Remote Source
|
||||
if ($this->_config->deployment('from', false) == false) {
|
||||
if (is_array($this->_config->deployment('source', null))) {
|
||||
if ($stage == 'pre-deploy') {
|
||||
array_unshift($tasksToRun, 'scm/clone');
|
||||
} elseif ($stage == 'post-deploy') {
|
||||
array_unshift($tasksToRun, 'scm/remove-clone');
|
||||
}
|
||||
}
|
||||
// Look for Remote Source
|
||||
if (is_array($this->_config->deployment('source', null))) {
|
||||
if ($stage == 'pre-deploy') {
|
||||
array_unshift($tasksToRun, 'scm/clone');
|
||||
} elseif ($stage == 'post-deploy') {
|
||||
array_unshift($tasksToRun, 'scm/remove-clone');
|
||||
}
|
||||
}
|
||||
|
||||
if (count($tasksToRun) == 0) {
|
||||
|
@ -31,6 +31,11 @@ abstract class Mage_Task_TaskAbstract
|
||||
return $this->_config;
|
||||
}
|
||||
|
||||
public function getActionOption($name, $value = false)
|
||||
{
|
||||
return Mage_Console::getActionOption($name, $value);
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user