use of jetbrains.buildServer.powershell.common.PowerShellExecutionMode in project teamcity-powershell by JetBrains.
the class BasePowerShellService method makeProgramCommandLine.
@NotNull
@Override
public ProgramCommandLine makeProgramCommandLine() throws RunBuildException {
final PowerShellInfo info = selectTool();
final BuildProgressLogger buildLogger = getBuild().getBuildLogger();
final String psExecutable = info.getExecutablePath();
final String workDir = getWorkingDirectory().getPath();
final PowerShellExecutionMode mode = PowerShellExecutionMode.fromString(getRunnerParameters().get(RUNNER_EXECUTION_MODE));
buildLogger.message("PowerShell Executable: " + psExecutable);
buildLogger.message("Working directory: " + workDir);
if (PowerShellExecutionMode.STDIN == mode) {
return getStdInCommandLine(info, getEnv(info), workDir, generateCommand(info));
} else if (PowerShellExecutionMode.PS1 == mode) {
return getFileCommandLine(info, getEnv(info), workDir, generateArguments(info));
} else {
throw new RunBuildException("Could not select PowerShell tool for mode [" + mode + "]");
}
}
use of jetbrains.buildServer.powershell.common.PowerShellExecutionMode in project teamcity-powershell by JetBrains.
the class PowerShellCommandLineProvider method provideCommandLine.
@NotNull
public List<String> provideCommandLine(@NotNull final PowerShellInfo info, @NotNull final Map<String, String> runnerParams, @NotNull final File scriptFile, final boolean useExecutionPolicy) throws RunBuildException {
final List<String> result = new ArrayList<String>();
final PowerShellExecutionMode mod = PowerShellExecutionMode.fromString(runnerParams.get(RUNNER_EXECUTION_MODE));
if (mod == null) {
throw new RunBuildException("'" + RUNNER_EXECUTION_MODE + "' runner parameter is not defined");
}
// version must be the 1st arg after executable path
addVersion(result, runnerParams, info);
if (!StringUtil.isEmptyOrSpaces(runnerParams.get(RUNNER_NO_PROFILE))) {
result.add("-NoProfile");
}
result.add("-NonInteractive");
addCustomArguments(result, runnerParams, RUNNER_CUSTOM_ARGUMENTS);
if (useExecutionPolicy) {
addExecutionPolicyPreference(result);
}
addScriptBody(result, mod, scriptFile, runnerParams);
return result;
}
Aggregations