Search in sources :

Example 16 with ProcessWrapper

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();
}
Also used : ProcessWrapper(com.thoughtworks.go.util.ProcessWrapper)

Example 17 with ProcessWrapper

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;
}
Also used : ProcessWrapper(com.thoughtworks.go.util.ProcessWrapper)

Example 18 with ProcessWrapper

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")));
}
Also used : ProcessWrapper(com.thoughtworks.go.util.ProcessWrapper) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Aggregations

ProcessWrapper (com.thoughtworks.go.util.ProcessWrapper)18 Test (org.junit.jupiter.api.Test)6 DisabledOnOs (org.junit.jupiter.api.condition.DisabledOnOs)3 KillAllChildProcessTask (com.thoughtworks.go.domain.KillAllChildProcessTask)2 Builder (com.thoughtworks.go.domain.builder.Builder)2 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)2 DefaultGoPublisher (com.thoughtworks.go.work.DefaultGoPublisher)2 IOException (java.io.IOException)2 TestOnly (org.jetbrains.annotations.TestOnly)1 Test (org.junit.Test)1 Timeout (org.junit.jupiter.api.Timeout)1 EnabledOnOs (org.junit.jupiter.api.condition.EnabledOnOs)1