mirror of
https://github.com/andres-montanez/Magallanes
synced 2024-05-03 14:33:15 +02:00
Merge branch 'master' into develop
This commit is contained in:
commit
3462530883
|
@ -61,6 +61,26 @@ class ReleaseTask extends AbstractTask implements IsReleaseAware, SkipOnOverride
|
|||
// and awk parameters need special care depending on the executing shell
|
||||
$resultFetch = $this->runCommandRemote("ls -ld .", $directoryInfos);
|
||||
if (!empty($directoryInfos)) {
|
||||
|
||||
|
||||
// break $directoryInfos by line break
|
||||
// to exclude unwanted line(s)
|
||||
$lines = explode("\n", $directoryInfos);
|
||||
$filtered_lines = array();
|
||||
foreach ($lines as $line) {
|
||||
|
||||
// exclude line that starts with 'Identity added'
|
||||
// e.g.: from ssh with ProxyCommand / proxy jump
|
||||
if (stripos($line, "Identity added") !== FALSE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$filtered_lines[] = $line;
|
||||
}
|
||||
// reconstruct $directoryInfos using the filtered lines
|
||||
$directoryInfos = implode("\n", $filtered_lines);
|
||||
|
||||
|
||||
//uniformize format as it depends on the system deployed on
|
||||
$directoryInfos = trim(str_replace(array(" ", "\t"), ' ', $directoryInfos));
|
||||
$infoArray = explode(' ', $directoryInfos);
|
||||
|
|
|
@ -95,7 +95,7 @@ class RsyncTask extends BaseStrategyTaskAbstract implements IsReleaseAware
|
|||
|
||||
$command = 'rsync -avz '
|
||||
. $strategyFlags . ' '
|
||||
. '--rsh="ssh ' . $this->getConfig()->getHostIdentityFileOption() . '-p' . $this->getConfig()->getHostPort() . '" '
|
||||
. '--rsh="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ' . $this->getConfig()->getHostIdentityFileOption() . '-p' . $this->getConfig()->getHostPort() . '" '
|
||||
. $this->excludes($excludes) . ' '
|
||||
. $this->excludesListFile($excludesListFilePath) . ' '
|
||||
. $this->getConfig()->deployment('from') . ' '
|
||||
|
|
|
@ -45,8 +45,7 @@ class TarGzTask extends BaseStrategyTaskAbstract implements IsReleaseAware
|
|||
$this->checkOverrideRelease();
|
||||
|
||||
$excludes = $this->getExcludes();
|
||||
$excludesListFilePath = $this->getConfig()->deployment('excludes_file', '');
|
||||
;
|
||||
$excludesListFilePath = $this->getConfig()->deployment('excludes_file', '');
|
||||
|
||||
// If we are working with releases
|
||||
$deployToDirectory = $this->getConfig()->deployment('to');
|
||||
|
@ -64,6 +63,10 @@ class TarGzTask extends BaseStrategyTaskAbstract implements IsReleaseAware
|
|||
$remoteTarGz = basename($localTarGz);
|
||||
$excludeCmd = '';
|
||||
foreach ($excludes as $excludeFile) {
|
||||
if (strpos($excludeFile, '*') !== false) {
|
||||
$excludeFile = '"' . $excludeFile . '"';
|
||||
}
|
||||
|
||||
$excludeCmd .= ' --exclude=' . $excludeFile;
|
||||
}
|
||||
|
||||
|
|
139
Mage/Task/BuiltIn/Filesystem/SymlinkTask.php
Normal file
139
Mage/Task/BuiltIn/Filesystem/SymlinkTask.php
Normal file
|
@ -0,0 +1,139 @@
|
|||
<?php
|
||||
namespace Mage\Task\BuiltIn\Filesystem;
|
||||
|
||||
use Mage\Task\AbstractTask;
|
||||
use Mage\Config\RequiredConfigNotFoundException;
|
||||
|
||||
/**
|
||||
* Task for creating a symbolic link. Change will be done on local or
|
||||
* remote host depending on the stage of the deployment.
|
||||
*
|
||||
* Usage :
|
||||
* pre-deploy:
|
||||
* - filesystem/symlink: {link:/path/to/symlink, target: /path/to/target}
|
||||
* on-deploy:
|
||||
* - filesystem/symlink: {link:/path/to/symlink, target: /path/to/target}
|
||||
*
|
||||
* @author Jérémy Huet <jeremy.huet@gmail.com>
|
||||
*/
|
||||
class SymlinkTask extends AbstractTask
|
||||
{
|
||||
/**
|
||||
* The name of the symlink including full path to it.
|
||||
*
|
||||
* If the stage is on local host you should give full paths. If on remote
|
||||
* you may give full or relative to the current release directory paths.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $link;
|
||||
|
||||
/**
|
||||
* The target to wich the symlink should point to including full path to it.
|
||||
*
|
||||
* If the stage is on local host you should give full paths. If on remote
|
||||
* you may give full or relative to the current release directory paths.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $target;
|
||||
|
||||
/**
|
||||
* Initialize parameters.
|
||||
*
|
||||
* @throws RequiredConfigNotFoundException
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
if (! $this->getParameter('target')) {
|
||||
throw new RequiredConfigNotFoundException('Missing required target link.');
|
||||
}
|
||||
|
||||
$this->setTarget($this->getParameter('target'));
|
||||
if (!is_null($this->getParameter('link'))) {
|
||||
$this->setLink($this->getParameter('link'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return "Creating symbolic link [built-in]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$command = 'ln -fs ' . $this->getAbsolutPath($this->getTarget());
|
||||
if ($this->getLink()) {
|
||||
$command .= ' ' . $this->getAbsolutPath($this->getLink());
|
||||
}
|
||||
|
||||
$result = $this->runCommand($command);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function getAbsolutPath($path)
|
||||
{
|
||||
// For release
|
||||
if ($this->getStage() != 'pre-deploy' && $path[0] != '/' && $this->getConfig()->deployment('to')) {
|
||||
$releasesDirectory = trim($this->getConfig()->release('directory', 'releases'), '/') . '/' . $this->getConfig()->getReleaseId();
|
||||
return rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory . '/' . ltrim($path, '/');
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set link.
|
||||
*
|
||||
* @param string $link
|
||||
* @return SymlinkTask
|
||||
*/
|
||||
protected function setLink($link)
|
||||
{
|
||||
$this->link = $link;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getLink()
|
||||
{
|
||||
return $this->link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set target.
|
||||
*
|
||||
* @param string $target
|
||||
* @return SymlinkTask
|
||||
*/
|
||||
protected function setTarget($target)
|
||||
{
|
||||
$this->target = $target;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getTarget()
|
||||
{
|
||||
return $this->target;
|
||||
}
|
||||
}
|
|
@ -73,11 +73,13 @@ class ChangeBranchTask extends AbstractTask
|
|||
$command = $preCommand . 'git branch | grep \'*\' | cut -d\' \' -f 2';
|
||||
$currentBranch = 'master';
|
||||
$result = $this->runCommandLocal($command, $currentBranch);
|
||||
|
||||
self::$startingBranch = $currentBranch;
|
||||
|
||||
$scmData = $this->getConfig()->deployment('scm', false);
|
||||
|
||||
if ($result && is_array($scmData) && isset($scmData['branch']) && $scmData['branch'] != $currentBranch) {
|
||||
$command = 'git branch | grep \'' . $scmData['branch'] . '\' | tr -s \' \' | sed \'s/^[ ]//g\'';
|
||||
$command = $preCommand . 'git branch | grep \'' . $scmData['branch'] . '\' | tr -s \' \' | sed \'s/^[ ]//g\'';
|
||||
$isBranchTracked = '';
|
||||
$result = $this->runCommandLocal($command, $isBranchTracked);
|
||||
|
||||
|
@ -86,10 +88,8 @@ class ChangeBranchTask extends AbstractTask
|
|||
}
|
||||
|
||||
$branch = $this->getParameter('branch', $scmData['branch']);
|
||||
$command = 'git checkout ' . $branch;
|
||||
$command = $preCommand . 'git checkout ' . $branch;
|
||||
$result = $this->runCommandLocal($command) && $result;
|
||||
|
||||
self::$startingBranch = $currentBranch;
|
||||
} else {
|
||||
throw new SkipException;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ class CloneTask extends AbstractTask
|
|||
|
||||
// Create temporal directory for clone
|
||||
if (is_array($this->source)) {
|
||||
if (trim($this->source['temporal']) == '') {
|
||||
if (!isset($this->source['temporal']) || trim($this->source['temporal']) == '') {
|
||||
$this->source['temporal'] = sys_get_temp_dir();
|
||||
}
|
||||
$this->source['temporal'] = rtrim($this->source['temporal'], '/') . '/' . md5(microtime()) . '/';
|
||||
|
|
23
Mage/Task/BuiltIn/Symfony2/FrontControllerCleanTask.php
Normal file
23
Mage/Task/BuiltIn/Symfony2/FrontControllerCleanTask.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
namespace Task;
|
||||
|
||||
use Mage\Task\AbstractTask;
|
||||
|
||||
/**
|
||||
* @author Muhammad Surya Ihsanuddin <surya.kejawen@gmail.com>
|
||||
*/
|
||||
class FrontControllerCleanTask extends AbstractTask
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'Cleaning Project';
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
$command = 'rm -rf web/app_*.php';
|
||||
$result = $this->runCommandRemote($command);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
8
bin/mage
8
bin/mage
|
@ -22,12 +22,12 @@ if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
|
|||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
} else if (file_exists(__DIR__ . '/../../../autoload.php')) {
|
||||
require_once __DIR__ . '/../../../autoload.php';
|
||||
} else {
|
||||
require_once $baseDir . '/Mage/Autoload.php';
|
||||
$loader = new \Mage\Autoload();
|
||||
spl_autoload_register(array($loader, 'autoLoad'));
|
||||
}
|
||||
|
||||
require_once $baseDir . '/Mage/Autoload.php';
|
||||
$loader = new \Mage\Autoload();
|
||||
spl_autoload_register(array($loader, 'autoLoad'));
|
||||
|
||||
// Clean arguments
|
||||
array_shift($argv);
|
||||
|
||||
|
|
1035
build/logs/coverage.xml
Normal file
1035
build/logs/coverage.xml
Normal file
File diff suppressed because it is too large
Load diff
|
@ -6,7 +6,7 @@
|
|||
"type": "library",
|
||||
"keywords": ["deployment"],
|
||||
"require": {
|
||||
"php": ">=5.3"
|
||||
"php": ">=5.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.3.5",
|
||||
|
|
1266
composer.lock
generated
1266
composer.lock
generated
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue