Charset charset = null; if (computer != null) { charset = computer.getDefaultCharset(); this.charset = charset.name();
/** * Parses console output from a {@link ByteArrayOutputStream}. * @param output Output stream * @param logger Logger * @return Retrieved string or null if cannot retrieve it * @throws IOException Buffer flush error */ /*package*/ static @CheckForNull String getConsoleOutput( @Nonnull ByteArrayOutputStream output, @Nonnull Logger logger) throws IOException { String res = null; try { Computer computer = Computer.currentComputer(); if (computer != null) { Charset charset = computer.getDefaultCharset(); if (charset != null) { output.flush(); res = output.toString(charset.name()); } } } catch (UnsupportedEncodingException e) { // we couldn't parse, ignore logger.log(Level.FINE, "Unable to get a console output from launched command: {}", e); } return res; }
/** * Executes a command and reads the result to a string. It uses the launcher to run the command to make sure the * launcher decorator is used ie. docker.image step * * @param args command arguments * @return output from the command or {@code null} if the command returned a non zero code * @throws InterruptedException if interrupted */ @Nullable private String readFromProcess(String... args) throws InterruptedException { try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { ProcStarter ps = launcher.launch(); Proc p = launcher.launch(ps.cmds(args).stdout(baos)); int exitCode = p.join(); if (exitCode == 0) { return baos.toString(getComputer().getDefaultCharset().name()).replaceAll("[\t\r\n]+", " ").trim(); } else { return null; } } catch (IOException e) { e.printStackTrace(console.format("Error executing command '%s' : %s%n", Arrays.toString(args), e.getMessage())); } return null; }
mavenGlobalSettingsFile.write(mavenGlobalSettingsFileContent, getComputer().getDefaultCharset().name()); LOGGER.log(Level.FINE, "Created global config file {0}", new Object[]{mavenGlobalSettingsFile}); } catch (Exception e) {
mavenSettingsFile.write(mavenSettingsFileContent, getComputer().getDefaultCharset().name()); } catch (Exception e) { throw new IllegalStateException("Exception injecting Maven settings.xml " + mavenSettingsConfig.id +
/** * Creates the actual wrapper script file and sets the permissions. * * @param tempBinDir dir to create the script file * @param name the script file name * @param content contents of the file * @return * @throws InterruptedException when processing remote calls * @throws IOException when reading files */ private FilePath createWrapperScript(FilePath tempBinDir, String name, String content) throws IOException, InterruptedException { FilePath scriptFile = tempBinDir.child(name); envOverride.put(MVN_CMD, scriptFile.getRemote()); scriptFile.write(content, getComputer().getDefaultCharset().name()); scriptFile.chmod(0755); return scriptFile; }
ConsoleLogFilter maskSecretsFilter = MaskPasswordsConsoleLogFilter.newMaskPasswordsConsoleLogFilter(credentials, getComputer().getDefaultCharset()); MavenColorizerConsoleLogFilter mavenColorizerFilter = new MavenColorizerConsoleLogFilter(getComputer().getDefaultCharset().name());
Charset charset = null; if (computer != null) { charset = computer.getDefaultCharset(); this.charset = charset.name();
Charset charset = Computer.currentComputer().getDefaultCharset(); this.charset = charset.name();
Charset charset = Computer.currentComputer().getDefaultCharset(); this.charset = charset.name();
Charset charset = Computer.currentComputer().getDefaultCharset(); this.charset = charset.name();
try { try { Charset charset = Computer.currentComputer().getDefaultCharset(); this.charset = charset.name();