public function saveProject($url, $branch = null) { $name = $this->getNameFromRepository($url, $branch); $path = escapeshellarg($this->getProjectDirectory($name)); $url = escapeshellarg($url); $this->executor->executeCommand(sprintf('git clone -b %s %s %s', $branch ?: "master", $url, $path)); }
public function getInspectResults($skipCache = false) { if (null === $this->inspectResults || true === $skipCache) { try { $data = $this->executor->executeCommand(sprintf('docker inspect %s', $this->name), null, true); $data = json_decode($data, true); $this->inspectResults = $data[0]; } catch (ProcessFailedException $e) { } } return $this->inspectResults; }
/** * @param \Symfony\Component\Console\Output\OutputInterface $output * @param bool $useSudo * @param string $ssh * * @return CommandExecutor */ public function createExecutor(OutputInterface $output, $useSudo = false, $ssh = null) { $executor = new CommandExecutor(); $executor->setOutput($output); if ($useSudo) { $executor->setDecorator(new SudoDecorator(['docker'])); } $decorator = $this->getSSHDecorator($ssh); if ($decorator) { $executor->setDecorator($decorator); } return $executor; }
public function getRemoteIp(CommandExecutor $executor) { $matches['ip'] = '127.0.0.1'; $decorator = $executor->getDecorator(); if ($decorator instanceof SSHDecorator) { $verbose = $decorator->getVerbose(); $decorator->setVerbose(true); try { $executor->executeCommand('exit'); } catch (ProcessFailedException $e) { } $output = $executor->getLastErrorOutput(); $decorator->setVerbose($verbose); preg_match('/^debug1: Connecting to [\\w\\d.-]+ \\[(?<ip>[\\d.]+)\\] port \\d+/m', $output, $matches); } return $matches['ip']; }
private function setupPostRevceiveHook($image, $volume) { $gitDir = sprintf('%s/.git', $this->getVolumePathOnTarget($image, $volume)); $path = sprintf('%s/hooks/post-receive', $gitDir); $script = $this->getPostReceiveScript($image, $volume); $this->executor->executeCommand(sprintf('cat > %s', escapeshellarg($path)), $script); $this->executor->executeCommand(sprintf('chmod a+x %s', escapeshellarg($path))); $this->executor->executeCommand(sprintf('git --git-dir=%s config --replace-all receive.denyCurrentBranch ignore', $gitDir)); $this->executor->executeCommand(sprintf('git --git-dir=%s config --replace-all receive.denyDeleteCurrent ignore', $gitDir)); }