use of com.thoughtworks.go.util.ProcessWrapper in project gocd by gocd.
the class CommandLine method run.
public int run(ConsoleOutputStreamConsumer outputStreamConsumer, ProcessTag processTag, String... input) {
LOG.debug("Running {}", this);
addInput(input);
SafeOutputStreamConsumer safeStreamConsumer = new SafeOutputStreamConsumer(outputStreamConsumer);
safeStreamConsumer.addArguments(arguments);
safeStreamConsumer.addSecrets(secrets);
ProcessWrapper process = execute(safeStreamConsumer, new EnvironmentVariableContext(), processTag);
return process.waitForExit();
}
use of com.thoughtworks.go.util.ProcessWrapper in project gocd by gocd.
the class CommandLine method startProcess.
private ProcessWrapper startProcess(EnvironmentVariableContext environmentVariableContext, ConsoleOutputStreamConsumer consumer, ProcessTag processTag) throws IOException {
ProcessWrapper process = createProcess(environmentVariableContext, consumer, processTag, ERROR_STREAM_PREFIX_FOR_SCRIPTS);
process.closeOutputStream();
return process;
}
use of com.thoughtworks.go.util.ProcessWrapper in project gocd by gocd.
the class CommandLineTest method shouldLogPasswordsOnOutputAsStarsUnderLinux.
@Test
@DisabledOnOs(OS.WINDOWS)
void shouldLogPasswordsOnOutputAsStarsUnderLinux() {
CommandLine line = CommandLine.createCommandLine("echo").withArg("My Password is:").withArg(new PasswordArgument("secret")).withEncoding("utf-8");
InMemoryStreamConsumer output = new InMemoryStreamConsumer();
InMemoryStreamConsumer displayOutputStreamConsumer = InMemoryStreamConsumer.inMemoryConsumer();
ProcessWrapper processWrapper = line.execute(output, new EnvironmentVariableContext(), null);
processWrapper.waitForExit();
assertThat(output.getAllOutput(), containsString("secret"));
assertThat(displayOutputStreamConsumer.getAllOutput(), not(containsString("secret")));
}
Aggregations