fixed wipe feature by removing the double quotes in the shell command, added 'symlink to current build copy' feature
This commit is contained in:
parent
8bf1d09afd
commit
1522b6d26b
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -17,3 +17,4 @@ PHPCI/Store/MigrationStore.php
|
|||
PHPCI/Store/Base/MigrationStoreBase.php
|
||||
local_vars.php
|
||||
Tests/PHPCI/config.yml
|
||||
/nbproject/
|
|
@ -26,6 +26,7 @@ class CopyBuild implements \PHPCI\Plugin
|
|||
protected $wipe;
|
||||
protected $phpci;
|
||||
protected $build;
|
||||
protected $symlink;
|
||||
|
||||
/**
|
||||
* Set up the plugin, configure options, etc.
|
||||
|
@ -41,6 +42,7 @@ class CopyBuild implements \PHPCI\Plugin
|
|||
$this->directory = isset($options['directory']) ? $options['directory'] : $path;
|
||||
$this->wipe = isset($options['wipe']) ? (bool)$options['wipe'] : false;
|
||||
$this->ignore = isset($options['respect_ignore']) ? (bool)$options['respect_ignore'] : false;
|
||||
$this->symlink = isset($options['symlink_to_current']) ? $options['symlink_to_current'] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,6 +67,10 @@ class CopyBuild implements \PHPCI\Plugin
|
|||
|
||||
$this->deleteIgnoredFiles();
|
||||
|
||||
if ($success && $this->symlink) {
|
||||
$success = $this->createSymlinkToCurrentBuild();
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
|
@ -75,7 +81,7 @@ class CopyBuild implements \PHPCI\Plugin
|
|||
protected function wipeExistingDirectory()
|
||||
{
|
||||
if ($this->wipe === true && $this->directory != '/' && is_dir($this->directory)) {
|
||||
$cmd = 'rm -Rf "%s*"';
|
||||
$cmd = 'rm -Rf %s*';
|
||||
$success = $this->phpci->executeCommand($cmd, $this->directory);
|
||||
|
||||
if (!$success) {
|
||||
|
@ -99,4 +105,30 @@ class CopyBuild implements \PHPCI\Plugin
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create symlink to current copy of build directory.
|
||||
* Info: Does not work on windows systems.
|
||||
* @return boolean
|
||||
*/
|
||||
protected function createSymlinkToCurrentBuild()
|
||||
{
|
||||
$success = true;
|
||||
|
||||
if (!IS_WIN) {
|
||||
$cmd = 'rm "%s" && ln -s "%s" "%s"';
|
||||
|
||||
$dir = rtrim($this->directory, '/') . '/';
|
||||
$this->phpci->log('Try to create symlink: '.$this->symlink.' --> '.$dir.$this->build->getId());
|
||||
$success = $this->phpci->executeCommand($cmd, $this->symlink, $dir.$this->build->getId(), $this->symlink);
|
||||
|
||||
if (!$success) {
|
||||
$this->phpci->logFailure('Unable to create symlink: '.$this->symlink.' --> '.$dir.$this->build->getId());
|
||||
} else {
|
||||
$this->phpci->log('Symlink successfully created.');
|
||||
}
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue