Switching executeCommand() to use sprintf for parameters, and all the plugins to pass params separately. See #12, closes #24
This commit is contained in:
parent
be37a5e821
commit
a5a03e1f07
|
@ -86,8 +86,10 @@ class Builder
|
|||
$this->store->save($this->build);
|
||||
}
|
||||
|
||||
public function executeCommand($command)
|
||||
public function executeCommand()
|
||||
{
|
||||
$command = call_user_func_array('sprintf', func_get_args());
|
||||
|
||||
$this->log('Executing: ' . $command, ' ');
|
||||
|
||||
$output = '';
|
||||
|
@ -179,7 +181,7 @@ class Builder
|
|||
protected function removeBuild()
|
||||
{
|
||||
$this->log('Removing build.');
|
||||
shell_exec('rm -Rf ' . $this->buildPath);
|
||||
shell_exec(sprintf('rm -Rf "%s"', $this->buildPath));
|
||||
}
|
||||
|
||||
protected function executePlugins($stage)
|
||||
|
|
|
@ -44,7 +44,7 @@ class LocalBuild extends Build
|
|||
}
|
||||
}
|
||||
else {
|
||||
$builder->executeCommand(sprintf("cp -Rf %s %s/", $reference, $buildPath));
|
||||
$builder->executeCommand('cp -Rf "%s" "%s/"', $reference, $buildPath);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -48,7 +48,7 @@ abstract class RemoteGitBuild extends Build
|
|||
|
||||
protected function cloneByHttp(Builder $builder, $to)
|
||||
{
|
||||
return $builder->executeCommand('git clone -b ' .$this->getBranch() . ' ' .$this->getCloneUrl().' '.$to);
|
||||
return $builder->executeCommand('git clone -b %s %s "%s"', $this->getBranch(), $this->getCloneUrl(), $to);
|
||||
}
|
||||
|
||||
protected function cloneBySsh(Builder $builder, $to)
|
||||
|
@ -59,7 +59,7 @@ abstract class RemoteGitBuild extends Build
|
|||
chmod($keyFile, 0600);
|
||||
|
||||
// Use the key file to do an SSH clone:
|
||||
$success = $builder->executeCommand('ssh-agent ssh-add '.$keyFile.' && git clone -b ' .$build->getBranch() . ' ' .$this->getCloneUrl().' '.$to.' && ssh-agent -k');
|
||||
$success = $builder->executeCommand('ssh-agent ssh-add "%s" && git clone -b %s %s "%s" && ssh-agent -k', $keyFile, $build->getBranch(), $this->getCloneUrl(), $to);
|
||||
|
||||
// Remove the key file:
|
||||
unlink($keyFile);
|
||||
|
|
|
@ -17,6 +17,6 @@ class Composer implements \PHPCI\Plugin
|
|||
|
||||
public function execute()
|
||||
{
|
||||
return $this->phpci->executeCommand(PHPCI_DIR . 'composer.phar --prefer-dist --working-dir=' . $this->directory . ' ' . $this->action);
|
||||
return $this->phpci->executeCommand(PHPCI_DIR . 'composer.phar --prefer-dist --working-dir="%s" %s', $this->directory, $this->action);
|
||||
}
|
||||
}
|
|
@ -17,8 +17,9 @@ class PhpCodeSniffer implements \PHPCI\Plugin
|
|||
|
||||
public function execute()
|
||||
{
|
||||
if(count($this->phpci->ignore))
|
||||
{
|
||||
$ignore = '';
|
||||
|
||||
if(count($this->phpci->ignore)) {
|
||||
$ignore = array_map(function($item)
|
||||
{
|
||||
return substr($item, -1) == '/' ? $item . '*' : $item . '/*';
|
||||
|
@ -27,6 +28,6 @@ class PhpCodeSniffer implements \PHPCI\Plugin
|
|||
$ignore = ' --ignore=' . implode(',', $ignore);
|
||||
}
|
||||
|
||||
return $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpcs --standard=' . $this->standard . $ignore. ' ' . $this->phpci->buildPath);
|
||||
return $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpcs --standard=%s %s "%s"', $this->standard, $ignore, $this->phpci->buildPath);
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ class PhpCpd implements \PHPCI\Plugin
|
|||
|
||||
public function execute()
|
||||
{
|
||||
$ignore = '';
|
||||
if(count($this->phpci->ignore))
|
||||
{
|
||||
$ignore = array_map(function($item)
|
||||
|
@ -27,6 +28,6 @@ class PhpCpd implements \PHPCI\Plugin
|
|||
$ignore = implode('', $ignore);
|
||||
}
|
||||
|
||||
return $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpcpd' . $ignore . ' ' . $this->phpci->buildPath);
|
||||
return $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpcpd %s "%s"', $ignore, $this->phpci->buildPath);
|
||||
}
|
||||
}
|
|
@ -13,6 +13,8 @@ class PhpMessDetector implements \PHPCI\Plugin
|
|||
|
||||
public function execute()
|
||||
{
|
||||
$ignore = '';
|
||||
|
||||
if(count($this->phpci->ignore))
|
||||
{
|
||||
$ignore = array_map(function($item)
|
||||
|
@ -23,6 +25,6 @@ class PhpMessDetector implements \PHPCI\Plugin
|
|||
$ignore = ' --exclude ' . implode(',', $ignore);
|
||||
}
|
||||
|
||||
return $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpmd ' . $this->phpci->buildPath . ' text codesize,unusedcode,naming' . $ignore);
|
||||
return $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpmd "%s" text codesize,unusedcode,naming %s', $this->phpci->buildPath, $ignore);
|
||||
}
|
||||
}
|
|
@ -62,7 +62,7 @@ class PhpUnit implements \PHPCI\Plugin
|
|||
$curdir = getcwd();
|
||||
chdir($this->phpci->buildPath.'/'.$this->runFrom);
|
||||
}
|
||||
$success = $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpunit ' . $this->args . ' -c ' . $this->phpci->buildPath . $configPath);
|
||||
$success = $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpunit %s -c "%s"', $this->args, $this->phpci->buildPath . $configPath);
|
||||
if ($this->runFrom) {
|
||||
chdir($curdir);
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class PhpUnit implements \PHPCI\Plugin
|
|||
else {
|
||||
$curdir = getcwd();
|
||||
chdir($this->phpci->buildPath);
|
||||
$success = $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpunit ' . $this->args . ' ' . $this->phpci->buildPath . $dirPath);
|
||||
$success = $this->phpci->executeCommand(PHPCI_BIN_DIR . 'phpunit %s "%s"', $this->args, $this->phpci->buildPath . $dirPath);
|
||||
chdir($curdir);
|
||||
return $success;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue