in powershell-agent/src/main/java/jetbrains/buildServer/powershell/agent/ScriptGenerator.java [43:75]
public File generateScript(@NotNull final Map<String, String> runnerParameters,
@NotNull final File buildCheckoutDir,
@NotNull final File buildTempDir,
@NotNull final File workingDir) throws RunBuildException {
final PowerShellScriptMode scriptMode = PowerShellScriptMode.fromString(runnerParameters.get(RUNNER_SCRIPT_MODE));
File scriptFile;
if (PowerShellScriptMode.FILE == scriptMode) {
final String scriptFilePath = runnerParameters.get(RUNNER_SCRIPT_FILE);
scriptFile = FileUtil.resolvePath(buildCheckoutDir, scriptFilePath);
if (!scriptFile.isFile()) {
if (LOG.isDebugEnabled()) {
LOG.debug(scriptFilePath + " was not not found in checkout directory. Trying to resolve against working directory");
}
scriptFile = FileUtil.resolvePath(workingDir, scriptFilePath);
}
} else {
String sourceScript = runnerParameters.get(RUNNER_SCRIPT_CODE);
if (isEmptyOrSpaces(sourceScript)) {
throw new RunBuildException("Empty build script");
}
sourceScript = convertLineSeparators(sourceScript, "\r\n");
/*if (PowerShellExecutionMode.STDIN.equals(PowerShellExecutionMode.fromString(runnerParameters.get(RUNNER_EXECUTION_MODE)))) {
//some newlines are necessary to workaround -Command - issues, like TW-19771
sourceScript = " \r\n \r\n \r\n" + sourceScript + "\r\n \r\n \r\n ";
}*/
scriptFile = writeToTempFile(buildTempDir, sourceScript, runnerParameters);
}
if (!scriptFile.isFile()) {
throw new RunBuildException("Cannot find PowerShell script by path specified in build configuration settings: "
+ scriptFile.getAbsolutePath() + " (absolute path on agent). Please check that the specified path is correct.");
}
return scriptFile;
}