use of jetbrains.buildServer.agent.BuildProgressLogger 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.agent.BuildProgressLogger in project teamcity-powershell by JetBrains.
the class BasePowerShellService method getListeners.
@NotNull
@Override
public List<ProcessListener> getListeners() {
final boolean logToError = !StringUtil.isEmptyOrSpaces(getRunnerParameters().get(PowerShellConstants.RUNNER_LOG_ERR_TO_ERROR));
final BuildProgressLogger logger = getLogger();
return Collections.<ProcessListener>singletonList(new ProcessListenerAdapter() {
private final org.apache.log4j.Logger OUT_LOG = org.apache.log4j.Logger.getLogger("teamcity.out");
@Override
public void onStandardOutput(@NotNull final String text) {
logger.message(text);
OUT_LOG.info(text);
}
@Override
public void onErrorOutput(@NotNull final String text) {
if (logToError) {
logger.error(text);
} else {
logger.warning(text);
}
OUT_LOG.warn(text);
}
});
}
use of jetbrains.buildServer.agent.BuildProgressLogger in project teamcity-powershell by JetBrains.
the class BasePowerShellService method selectTool.
private PowerShellInfo selectTool() throws RunBuildException {
final BuildProgressLogger buildLogger = getBuild().getBuildLogger();
PowerShellInfo result;
if (getRunnerContext().isVirtualContext()) {
if (SystemInfo.isWindows) {
throw new RunBuildException("PowerShell is not supported on windows containers");
}
buildLogger.logMessage(internalize(createTextMessage("PowerShell is running in virtual agent context")));
result = VirtualPowerShellSupport.getVirtualPowerShell();
} else {
buildLogger.logMessage(internalize(createTextMessage("PowerShell running in non-virtual agent context")));
final PowerShellBitness bit = PowerShellBitness.fromString(getRunnerParameters().get(RUNNER_BITNESS));
final String version = getRunnerParameters().get(RUNNER_MIN_VERSION);
final PowerShellEdition edition = PowerShellEdition.fromString(getRunnerParameters().get(RUNNER_EDITION));
result = myInfoProvider.selectTool(bit, version, edition);
if (result == null) {
throw new RunBuildException("Could not select PowerShell for given bitness " + (bit == null ? "<Auto>" : bit.getDisplayName() + " and version " + (version == null ? "<Any>" : version)));
}
}
return result;
}
use of jetbrains.buildServer.agent.BuildProgressLogger in project teamcity-powershell by JetBrains.
the class PowerShellServiceUnix method executeWithWrapper.
private SimpleProgramCommandLine executeWithWrapper(@NotNull final Map<String, String> env, @NotNull final String workDir, @NotNull final String argsList) throws RunBuildException {
final File scriptFile = generateNixScriptFile(argsList);
final BuildProgressLogger buildLogger = getBuild().getBuildLogger();
buildLogger.message("Wrapper script: " + scriptFile);
buildLogger.message("Command: " + argsList);
enableExecution(scriptFile);
return new SimpleProgramCommandLine(env, workDir, scriptFile.getAbsolutePath(), Collections.<String>emptyList());
}
use of jetbrains.buildServer.agent.BuildProgressLogger in project teamcity-powershell by JetBrains.
the class PowerShellServiceWindows method getStdInCommandLine.
@Override
protected SimpleProgramCommandLine getStdInCommandLine(@NotNull final PowerShellInfo info, @NotNull final Map<String, String> env, @NotNull final String workDir, @NotNull final String command) throws RunBuildException {
final List<String> args = generateRunScriptArguments(command);
final String executable = myCommands.getCMDWrappedCommand(info, getEnvironmentVariables());
final BuildProgressLogger buildLogger = getBuild().getBuildLogger();
buildLogger.message("Executable wrapper: " + executable);
buildLogger.message("Wrapper arguments: " + Arrays.toString(args.toArray()));
buildLogger.message("Command: " + command);
return new SimpleProgramCommandLine(env, workDir, executable, args);
}
Aggregations