use of com.synopsys.integration.executable.ProcessBuilderRunner in project synopsys-detect by blackducksoftware.
the class BatteryDetectRunner method executeDetectScript.
private DetectOutput executeDetectScript(List<String> detectArguments) throws ExecutableRunnerException {
List<String> shellArguments = new ArrayList<>();
String target = "";
if (SystemUtils.IS_OS_WINDOWS) {
target = "powershell";
shellArguments.add("\"[Net.ServicePointManager]::SecurityProtocol = 'tls12'; irm https://detect.synopsys.com/detect.ps1?$(Get-Random) | iex; detect\"");
} else {
File scriptTarget = new File(scriptDirectory, "detect.sh");
if (scriptTarget.exists()) {
Assertions.assertTrue(scriptTarget.delete(), "Failed to cleanup an existing detect shell script. This file is cleaned up to ensure latest script is always used.");
}
ExecutableOutput downloadOutput = downloadDetectBash(scriptTarget);
Assertions.assertTrue(downloadOutput.getReturnCode() == 0 && scriptTarget.exists(), "Something went wrong downloading the detect script.");
Assertions.assertTrue(scriptTarget.setExecutable(true), "Failed to change script permissions to execute. The downloaded detect script must be executable.");
target = scriptTarget.toString();
}
shellArguments.addAll(detectArguments);
Map<String, String> environmentVariables = new HashMap<>();
if (StringUtils.isNotBlank(detectVersion)) {
environmentVariables.put("DETECT_LATEST_RELEASE_VERSION", detectVersion);
}
Executable executable = Executable.create(outputDirectory, environmentVariables, target, shellArguments);
ProcessBuilderRunner executableRunner = new ProcessBuilderRunner(new Slf4jIntLogger(logger));
ExecutableOutput result = executableRunner.execute(executable);
Assertions.assertEquals(0, result.getReturnCode(), "Detect returned a non-zero exit code:" + result.getReturnCode());
List<String> lines = result.getStandardOutputAsList();
Assertions.assertTrue(lines.size() > 0, "Detect wrote nothing to standard out.");
return new DetectOutput(result.getStandardOutputAsList());
}
use of com.synopsys.integration.executable.ProcessBuilderRunner in project synopsys-detect by blackducksoftware.
the class BatteryDetectRunner method downloadDetectBash.
private ExecutableOutput downloadDetectBash(File target) throws ExecutableRunnerException {
List<String> shellArguments = new ArrayList<>();
shellArguments.add("-s");
shellArguments.add("-L");
shellArguments.add("https://detect.synopsys.com/detect.sh");
shellArguments.add("-o");
shellArguments.add(target.toString());
Executable executable = Executable.create(outputDirectory, new HashMap<>(), "curl", shellArguments);
ProcessBuilderRunner executableRunner = new ProcessBuilderRunner(new Slf4jIntLogger(logger));
return executableRunner.execute(executable);
}
use of com.synopsys.integration.executable.ProcessBuilderRunner in project synopsys-detect by blackducksoftware.
the class BatteryDetectRunner method executeDetectJar.
private DetectOutput executeDetectJar(DetectJar detectJar, List<String> detectArguments) throws ExecutableRunnerException {
List<String> javaArguments = new ArrayList<>();
javaArguments.add("-jar");
javaArguments.add(detectJar.getJar());
javaArguments.addAll(detectArguments);
ProcessBuilderRunner executableRunner = new ProcessBuilderRunner(new Slf4jIntLogger(logger));
ExecutableOutput result = executableRunner.execute(Executable.create(outputDirectory, detectJar.getJava(), javaArguments));
Assertions.assertEquals(0, result.getReturnCode(), "Detect returned a non-zero exit code:" + result.getReturnCode());
List<String> lines = result.getStandardOutputAsList();
Assertions.assertTrue(lines.size() > 0, "Detect wrote nothing to standard out.");
return new DetectOutput(result.getStandardOutputAsList());
}
use of com.synopsys.integration.executable.ProcessBuilderRunner in project blackduck-docker-inspector by blackducksoftware.
the class UpdateArtifactoryPropertiesTask method curlResponse.
public ExecutableOutput curlResponse(final List<String> curlArgs) throws ExecutableRunnerException {
final File workingDirectory = new File(System.getProperty("user.dir"));
final List<String> command = new ArrayList<>(Collections.singletonList("curl"));
command.addAll(curlArgs);
final Executable executable = new Executable(workingDirectory, new HashMap<>(), command);
final ProcessBuilderRunner processBuilderRunner = new ProcessBuilderRunner(logger);
return processBuilderRunner.execute(executable);
}
Aggregations