1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 09:18:48 +02:00

Put back the stronger variable replacement

Summary: This puts back the stronger variable replacement that was missed the last update to D7519.

Test Plan: Re-ran a remote build that had variables in the command and everything worked as expected.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T1049

Differential Revision: https://secure.phabricator.com/D7539
This commit is contained in:
James Rhodes 2013-11-08 18:36:48 -08:00 committed by epriestley
parent 8f52778f32
commit 197e9b6f49

View file

@ -26,20 +26,38 @@ final class RemoteCommandBuildStepImplementation
$settings = $this->getSettings(); $settings = $this->getSettings();
$parameters = array();
$matches = array();
$variables = $this->retrieveVariablesFromBuild($build);
$command = $settings['command'];
preg_match_all(
"/\\\$\\{(?P<name>[a-z]+)\\}/",
$command,
$matches);
foreach ($matches["name"] as $match) {
$parameters[] = idx($variables, $match, "");
}
$command = str_replace("%", "%%", $command);
$command = preg_replace("/\\\$\\{(?P<name>[a-z]+)\\}/", "%s", $command);
$command = vcsprintf(
$command,
$parameters);
$future = null; $future = null;
if (empty($settings['sshkey'])) { if (empty($settings['sshkey'])) {
$future = new ExecFuture( $future = new ExecFuture(
'ssh -o "StrictHostKeyChecking no" -p %s %s %s', 'ssh -o "StrictHostKeyChecking no" -p %s %s %s',
$settings['sshport'], $settings['sshport'],
$settings['sshuser'].'@'.$settings['sshhost'], $settings['sshuser'].'@'.$settings['sshhost'],
$this->mergeVariables($build, $settings['command'])); $command);
} else { } else {
$future = new ExecFuture( $future = new ExecFuture(
'ssh -o "StrictHostKeyChecking no" -p %s -i %s %s %s', 'ssh -o "StrictHostKeyChecking no" -p %s -i %s %s %s',
$settings['sshport'], $settings['sshport'],
$settings['sshkey'], $settings['sshkey'],
$settings['sshuser'].'@'.$settings['sshhost'], $settings['sshuser'].'@'.$settings['sshhost'],
$this->mergeVariables($build, $settings['command'])); $command);
} }
$log_stdout = $build->createLog($build_step, "remote", "stdout"); $log_stdout = $build->createLog($build_step, "remote", "stdout");