in rake-runner-agent/src/jetbrains/buildServer/agent/rakerunner/scripting/BashShellScriptRunner.java [22:57]
public ExecResult run(@NotNull final String script,
@NotNull final String workingDirectory,
@Nullable final Map<String, String> environment) {
final File directory = new File(workingDirectory);
File scriptFile = null;
try {
try {
scriptFile = FileUtil.createTempFile(directory, "script", ".sh", true);
if (LOG.isDebugEnabled()) {
LOG.debug("Created file " + scriptFile.getAbsolutePath());
}
FileUtil.writeFileAndReportErrors(scriptFile, script);
if (LOG.isDebugEnabled()) {
LOG.debug("Script is:" + script);
}
} catch (IOException e) {
LOG.error("Failed to create temp file, error: ", e);
final ExecResult result = new ExecResult();
result.setStderr("Failed to create temp file, error: " + e.getMessage());
result.setException(e);
return result;
}
final ExecResult run = RunnerUtil.run(workingDirectory, environment, "/bin/bash", scriptFile.getAbsolutePath());
if (LOG.isDebugEnabled()) {
LOG.debug("Script ExecResult:" + run);
}
return run;
} finally {
try {
if (scriptFile != null) {
FileUtil.delete(scriptFile);
}
} catch (SecurityException ignored) {
}
}
}