Search in sources :

Example 6 with RunBuildException

use of jetbrains.buildServer.RunBuildException 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;
}
Also used : ArrayList(java.util.ArrayList) RunBuildException(jetbrains.buildServer.RunBuildException) PowerShellExecutionMode(jetbrains.buildServer.powershell.common.PowerShellExecutionMode) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with RunBuildException

use of jetbrains.buildServer.RunBuildException in project teamcity-powershell by JetBrains.

the class PowerShellServiceWindows method generateRunScriptArguments.

@NotNull
private List<String> generateRunScriptArguments(@NotNull final String argumentsToGenerate) throws RunBuildException {
    final File bat;
    try {
        bat = FileUtil.createTempFile(getBuildTempDirectory(), "powershell", ".bat", true);
        myFilesToRemove.add(bat);
        FileUtil.writeFileAndReportErrors(bat, "@" + argumentsToGenerate);
    } catch (IOException e) {
        throw new RunBuildException("Failed to generate .bat file");
    }
    return Arrays.asList("/c", bat.getPath());
}
Also used : RunBuildException(jetbrains.buildServer.RunBuildException) IOException(java.io.IOException) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

RunBuildException (jetbrains.buildServer.RunBuildException)7 NotNull (org.jetbrains.annotations.NotNull)6 File (java.io.File)2 IOException (java.io.IOException)2 BuildProgressLogger (jetbrains.buildServer.agent.BuildProgressLogger)2 PowerShellInfo (jetbrains.buildServer.powershell.agent.detect.PowerShellInfo)2 PowerShellExecutionMode (jetbrains.buildServer.powershell.common.PowerShellExecutionMode)2 ArrayList (java.util.ArrayList)1 PowerShellBitness (jetbrains.buildServer.powershell.common.PowerShellBitness)1 PowerShellEdition (jetbrains.buildServer.powershell.common.PowerShellEdition)1 PowerShellScriptMode (jetbrains.buildServer.powershell.common.PowerShellScriptMode)1