Class ShellCommandExecutor
- java.lang.Object
-
- org.datadog.jenkins.plugins.datadog.util.ShellCommandExecutor
-
public class ShellCommandExecutor extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ShellCommandExecutor.OutputParser<T>
static class
ShellCommandExecutor.ToStringOutputParser
-
Constructor Summary
Constructors Constructor Description ShellCommandExecutor(File executionFolder, Map<String,String> environment, long timeoutMillis)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
executeCommand(ShellCommandExecutor.OutputParser<T> outputParser, byte[] input, String... command)
Executes given shell command, supplies to it provided input, and returns parsed output<T> T
executeCommand(ShellCommandExecutor.OutputParser<T> outputParser, String... command)
Executes given shell command and returns parsed output<T> T
executeCommandReadingError(ShellCommandExecutor.OutputParser<T> errorParser, String... command)
Executes given shell command and returns parsed error stream
-
-
-
Method Detail
-
executeCommand
public <T> T executeCommand(ShellCommandExecutor.OutputParser<T> outputParser, String... command) throws IOException, InterruptedException, TimeoutException
Executes given shell command and returns parsed output- Type Parameters:
T
- Type of parsed command output- Parameters:
outputParser
- Parses that is used to process command outputcommand
- Command to be executed- Returns:
- Parsed command output
- Throws:
IOException
- If an error was encountered while writing command input or reading outputTimeoutException
- If timeout was reached while waiting for command to finishInterruptedException
- If current thread was interrupted while waiting for command to finish
-
executeCommand
public <T> T executeCommand(ShellCommandExecutor.OutputParser<T> outputParser, byte[] input, String... command) throws IOException, InterruptedException, TimeoutException
Executes given shell command, supplies to it provided input, and returns parsed output- Type Parameters:
T
- Type of parsed command output- Parameters:
outputParser
- Parses that is used to process command outputinput
- Bytes that are written to command's input streamcommand
- Command to be executed- Returns:
- Parsed command output
- Throws:
IOException
- If an error was encountered while writing command input or reading outputTimeoutException
- If timeout was reached while waiting for command to finishInterruptedException
- If current thread was interrupted while waiting for command to finish
-
executeCommandReadingError
public <T> T executeCommandReadingError(ShellCommandExecutor.OutputParser<T> errorParser, String... command) throws IOException, InterruptedException, TimeoutException
Executes given shell command and returns parsed error stream- Type Parameters:
T
- Type of parsed command output- Parameters:
errorParser
- Parses that is used to process command's error streamcommand
- Command to be executed- Returns:
- Parsed command output
- Throws:
IOException
- If an error was encountered while writing command input or reading outputTimeoutException
- If timeout was reached while waiting for command to finishInterruptedException
- If current thread was interrupted while waiting for command to finish
-
-