Java Code Examples for jetbrains.buildServer.ExecResult#getException()

The following examples show how to use jetbrains.buildServer.ExecResult#getException() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SrcToolExe.java    From teamcity-symbol-server with Apache License 2.0 6 votes vote down vote up
public ExecResult dumpSources(final File pdbFile, final BuildProgressLogger buildLogger){
  final GeneralCommandLine commandLine = new GeneralCommandLine();
  commandLine.setWorkDirectory(myPath.getParent());
  commandLine.setExePath(myPath.getPath());
  commandLine.addParameter(pdbFile.getAbsolutePath());
  commandLine.addParameter(DUMP_REFERENCES_SWITCH);
  commandLine.addParameter(ZERRO_ON_SUCCESS_SWITCH);

  buildLogger.message(String.format("Running command %s", commandLine.getCommandLineString()));

  final ExecResult execResult = SimpleCommandLineProcessRunner.runCommand(commandLine, null);
  if (execResult.getExitCode() != 0) {
    buildLogger.warning(String.format("%s completed with exit code %s.", SRCTOOL_EXE, execResult));
    buildLogger.warning("Stdout: " + execResult.getStdout());
    buildLogger.warning("Stderr: " + execResult.getStderr());
    final Throwable exception = execResult.getException();
    if(exception != null){
      buildLogger.exception(exception);
    }
  }
  return execResult;
}
 
Example 2
Source File: UserUIDAndGIDImpl.java    From TeamCity.Virtual with Apache License 2.0 6 votes vote down vote up
@Nullable
private String runCommand(@NotNull String command) {
  final GeneralCommandLine cmd = new GeneralCommandLine();
  cmd.setExePath("/bin/sh");
  cmd.addParameter("-c");
  cmd.addParameter(command);

  final ExecResult result = SimpleCommandLineProcessRunner.runCommand(cmd, new byte[0]);

  //noinspection ThrowableResultOfMethodCallIgnored
  if (result.getException() != null || result.getExitCode() != 0) {
    LOG.info(("Failed to call '" + command+ "'. Exit code: " + result.getExitCode() + "\n " + result.getStdout() + "\n" + result.getStderr()).trim());
    return null;
  }

  return result.getStdout().trim();
}
 
Example 3
Source File: JetSymbolsExe.java    From teamcity-symbol-server with Apache License 2.0 5 votes vote down vote up
private ExecResult executeCommandLine(GeneralCommandLine commandLine, BuildProgressLogger buildLogger) {
  buildLogger.message(String.format("Running command %s", commandLine.getCommandLineString()));
  final ExecResult execResult = SimpleCommandLineProcessRunner.runCommand(commandLine, null);
  if (execResult.getExitCode() != 0) {
    buildLogger.warning(String.format("%s completed with exit code %s.", SYMBOLS_EXE, execResult));
    buildLogger.warning("Stdout: " + execResult.getStdout());
    buildLogger.warning("Stderr: " + execResult.getStderr());
    final Throwable exception = execResult.getException();
    if(exception != null){
      buildLogger.exception(exception);
    }
  }
  return execResult;
}