diff --git a/PHPCI/Builder.php b/PHPCI/Builder.php index 651e6489..d04f8bd9 100644 --- a/PHPCI/Builder.php +++ b/PHPCI/Builder.php @@ -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) diff --git a/PHPCI/Model/Build/LocalBuild.php b/PHPCI/Model/Build/LocalBuild.php index 6edac398..f66dbdd3 100644 --- a/PHPCI/Model/Build/LocalBuild.php +++ b/PHPCI/Model/Build/LocalBuild.php @@ -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; diff --git a/PHPCI/Model/Build/RemoteGitBuild.php b/PHPCI/Model/Build/RemoteGitBuild.php index 7df16b08..db72a3d8 100644 --- a/PHPCI/Model/Build/RemoteGitBuild.php +++ b/PHPCI/Model/Build/RemoteGitBuild.php @@ -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); diff --git a/PHPCI/Plugin/Composer.php b/PHPCI/Plugin/Composer.php index ac73f7de..1760fb98 100644 --- a/PHPCI/Plugin/Composer.php +++ b/PHPCI/Plugin/Composer.php @@ -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); } } \ No newline at end of file diff --git a/PHPCI/Plugin/PhpCodeSniffer.php b/PHPCI/Plugin/PhpCodeSniffer.php index 9b7095c3..aeef9a6a 100644 --- a/PHPCI/Plugin/PhpCodeSniffer.php +++ b/PHPCI/Plugin/PhpCodeSniffer.php @@ -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); } } \ No newline at end of file diff --git a/PHPCI/Plugin/PhpCpd.php b/PHPCI/Plugin/PhpCpd.php index a57e8aa1..c4adbf0a 100644 --- a/PHPCI/Plugin/PhpCpd.php +++ b/PHPCI/Plugin/PhpCpd.php @@ -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); } } \ No newline at end of file diff --git a/PHPCI/Plugin/PhpMessDetector.php b/PHPCI/Plugin/PhpMessDetector.php index 3a43415c..57af0eb5 100644 --- a/PHPCI/Plugin/PhpMessDetector.php +++ b/PHPCI/Plugin/PhpMessDetector.php @@ -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); } } \ No newline at end of file diff --git a/PHPCI/Plugin/PhpUnit.php b/PHPCI/Plugin/PhpUnit.php index fbce90db..5b057c01 100644 --- a/PHPCI/Plugin/PhpUnit.php +++ b/PHPCI/Plugin/PhpUnit.php @@ -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; }