private function travisEncrypt($data, TravisYmlView $view, OutputInterface $output) { $output->writeln("Encrypting \"{$data}\"..."); $command = "travis encrypt \"{$data}\""; // change dir to target plugin since plugin will be in its own git repo if (!empty($view->pluginName)) { $command = "cd \"" . $view->getPluginRootFolder() . "\" && " . $command; } exec($command, $commandOutput, $returnCode); if ($returnCode !== 0) { throw new Exception("Cannot encrypt \"{$data}\" for travis! Please make sure you have the travis command line " . "utility installed (see http://blog.travis-ci.com/2013-01-14-new-client/).\n\n" . "return code: {$returnCode}\n\n" . "travis output:\n\n" . implode("\n", $commandOutput)); } if (empty($commandOutput)) { throw new Exception("Cannot parse travis encrypt output:\n\n" . implode("\n", $commandOutput)); } // when not executed from a command line travis encrypt will return only the encrypted data $encryptedData = $commandOutput[0]; if (substr($encryptedData, 0, 1) != '"' || substr($encryptedData, -1) != '"') { $encryptedData = '"' . addslashes($encryptedData) . '"'; } return "secure: " . $encryptedData; }