jetbrains.buildServer.agent.BuildProgressLogger Java Examples

The following examples show how to use jetbrains.buildServer.agent.BuildProgressLogger. 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: ArtifactPathHelperTest.java    From teamcity-symbol-server with Apache License 2.0 6 votes vote down vote up
@Test(dataProvider = "testPaths")
public void testPathTransformation(String prefix, String fileName, String expectedPath) {
  Mockery m = new Mockery();
  ExtensionHolder extensionHolder = m.mock(ExtensionHolder.class);
  BuildProgressLogger logger = m.mock(BuildProgressLogger.class);
  InternalPropertiesHolder propertiesHolder = m.mock(InternalPropertiesHolder.class);
  ArtifactPathHelper helper = new ArtifactPathHelper(extensionHolder);
  ZipPreprocessor zipPreprocessor = new ZipPreprocessor(logger, new File("."), propertiesHolder);

  m.checking(new Expectations(){{
    allowing(extensionHolder).getExtensions(with(ArchivePreprocessor.class));
    will(returnValue(Collections.singletonList(zipPreprocessor)));
  }});

  Assert.assertEquals(helper.concatenateArtifactPath(prefix, fileName), expectedPath);
}
 
Example #2
Source File: AllureBuildServiceAdapter.java    From allure-teamcity with Apache License 2.0 6 votes vote down vote up
private String getProgramPath() throws RunBuildException {

        BuildProgressLogger buildLogger = getLogger();
        String path = clientDirectory.toAbsolutePath().toString();
        String executableName = getExecutableName();

        String executableFile = path + File.separatorChar + "bin" + File.separatorChar + executableName;
        File file = new File(executableFile);

        if (!file.exists()) {
            throw new RunBuildException("Cannot find executable \'" + executableFile + "\'");
        }
        if (!file.setExecutable(true)) {
            buildLogger.message("Cannot set file: " + executableFile + " executable.");
        }
        return file.getAbsolutePath();

    }
 
Example #3
Source File: AllureBuildServiceAdapter.java    From allure-teamcity with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@NotNull
@Override
public ProgramCommandLine makeProgramCommandLine() throws RunBuildException {

    BuildProgressLogger buildLogger = getLogger();

    Map<String, String> envVariables = new HashMap<>(getRunnerContext()
            .getBuildParameters()
            .getEnvironmentVariables());
    Optional.ofNullable(getRunnerContext().getRunnerParameters().get(JavaRunnerConstants.TARGET_JDK_HOME))
            .ifPresent(javaHome -> envVariables.put("JAVA_HOME", javaHome));

    String programPath = getProgramPath();
    List<String> programArgs = getProgramArgs();

    buildLogger.message("Program environment variables: " + envVariables.toString());
    buildLogger.message("Program working directory: " + workingDirectory);
    buildLogger.message("Program path: " + programPath);
    buildLogger.message("Program args: " + programArgs.toString());

    return new SimpleProgramCommandLine(envVariables, workingDirectory, programPath, programArgs);
}
 
Example #4
Source File: BaseVM.java    From TeamCity.Virtual with Apache License 2.0 6 votes vote down vote up
@NotNull
public static BuildProcess block(@NotNull final BuildProgressLogger logger,
                                 @NotNull final String blockName,
                                 @NotNull final String blockText,
                                 @NotNull final BuildProcess proc) {
  return new DelegatingBuildProcess(new DelegatingBuildProcess.Action() {
    @NotNull
    @Override
    public BuildProcess startImpl() throws RunBuildException {
      logger.activityStarted(blockName, blockText, "vm");
      return proc;
    }

    @Override
    public void finishedImpl() {
      logger.activityFinished(blockName, "vm");
    }
  });
}
 
Example #5
Source File: JetSymbolsExe.java    From teamcity-symbol-server with Apache License 2.0 6 votes vote down vote up
private PdbType parsePdbType(final String[] output, final BuildProgressLogger buildLogger) {
  final StringBuilder outputBuilder = new StringBuilder();
  for (int index = 0; index < output.length; index++) {
    if (index > 0) {
      outputBuilder.append("\n");
    }
    outputBuilder.append(output[index]);
  }

  final String outputValue = outputBuilder.toString();
  final PdbType result = PdbType.parse(outputValue);
  if (result == PdbType.Undefined) {
    buildLogger.error(String.format("Cannot parse PDB type: %s", outputValue));
  }
  return result;
}
 
Example #6
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 #7
Source File: JetSymbolsExe.java    From teamcity-symbol-server with Apache License 2.0 5 votes vote down vote up
public PdbType getPdbType(File symbolsFile, BuildProgressLogger buildLogger) {
  final GeneralCommandLine commandLine = new GeneralCommandLine();
  commandLine.setExePath(myExePath.getPath());
  commandLine.addParameter(GET_PDB_TYPE_CMD);
  commandLine.addParameter(symbolsFile.getAbsolutePath());

  final ExecResult execResult = executeCommandLine(commandLine, buildLogger);
  if (execResult.getExitCode() == 0) {
    return parsePdbType(execResult.getOutLines(), buildLogger);
  } else {
    buildLogger.error("Cannot parse PDB type.");
    return PdbType.Undefined;
  }
}
 
Example #8
Source File: JetSymbolsExe.java    From teamcity-symbol-server with Apache License 2.0 5 votes vote down vote up
public ExecResult updatePortablePdbSourceUrls(final File symbolsFile, final File sourceUrlsFile, final BuildProgressLogger buildLogger) {
  final GeneralCommandLine commandLine = new GeneralCommandLine();
  commandLine.setExePath(myExePath.getPath());
  commandLine.addParameter(UPDATE_SOURCE_URLS_CMD);
  commandLine.addParameter(symbolsFile.getAbsolutePath());
  commandLine.addParameter(String.format("/i=%s", sourceUrlsFile.getPath()));

  return executeCommandLine(commandLine, buildLogger);
}
 
Example #9
Source File: JetSymbolsExe.java    From teamcity-symbol-server with Apache License 2.0 5 votes vote down vote up
public int dumpPdbGuidsToFile(Collection<File> files, File output, BuildProgressLogger buildLogger) throws IOException {
  final GeneralCommandLine commandLine = new GeneralCommandLine();
  commandLine.setExePath(myExePath.getPath());
  commandLine.addParameter(DUMP_SYMBOL_SIGN_CMD);
  commandLine.addParameter(String.format("/o=%s", output.getPath()));
  commandLine.addParameter(String.format("/i=%s", dumpPathsToFile(files).getPath()));

  final ExecResult execResult = executeCommandLine(commandLine, buildLogger);
  if (execResult.getExitCode() == 0 && !execResult.getStdout().isEmpty()) {
    buildLogger.message("Stdout: " + execResult.getStdout());
  }

  return execResult.getExitCode();
}
 
Example #10
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;
}
 
Example #11
Source File: PdbFilePatcher.java    From teamcity-symbol-server with Apache License 2.0 5 votes vote down vote up
public PdbFilePatcher(@NotNull final File workingDir,
                      @NotNull final JetSymbolsExe jetSymbolsExe,
                      @NotNull final PdbFilePatcherAdapterFactory patcheAdapterFactory,
                      @NotNull final BuildProgressLogger progressLogger) {
  myWorkingDir = workingDir;
  myPatcheAdapterFactory = patcheAdapterFactory;
  myJetSymbolsExe = jetSymbolsExe;
  myProgressLogger = progressLogger;
}
 
Example #12
Source File: JetSymbolsExe.java    From teamcity-symbol-server with Apache License 2.0 5 votes vote down vote up
public Collection<File> getReferencedSourceFiles(File symbolsFile, BuildProgressLogger buildLogger) {
  final GeneralCommandLine commandLine = new GeneralCommandLine();
  commandLine.setExePath(myExePath.getPath());
  commandLine.addParameter(LIST_SOURCES_CMD);
  commandLine.addParameter(symbolsFile.getAbsolutePath());

  final ExecResult execResult = executeCommandLine(commandLine, buildLogger);
  if (execResult.getExitCode() == 0) {
    return CollectionsUtil.convertAndFilterNulls(Arrays.asList(execResult.getOutLines()), File::new);
  } else {
    return Collections.emptyList();
  }
}
 
Example #13
Source File: PdbFilePatcherAdapterImpl.java    From teamcity-symbol-server with Apache License 2.0 5 votes vote down vote up
public PdbFilePatcherAdapterImpl(
  @NotNull final SrcSrvStreamBuilder srcSrvStreamBuilder,
  @NotNull final PdbStrExe pdbStrExe,
  @NotNull final SrcToolExe srcToolExe,
  @NotNull final BuildProgressLogger buildLogger) {
  mySrcSrvStreamBuilder = srcSrvStreamBuilder;
  myPdbStrExe = pdbStrExe;
  mySrcToolExe = srcToolExe;
  myBuildLogger = buildLogger;
}
 
Example #14
Source File: PortablePdbFilePatcherAdapterImpl.java    From teamcity-symbol-server with Apache License 2.0 5 votes vote down vote up
public PortablePdbFilePatcherAdapterImpl(
  @NotNull final SourceLinkStreamBuilder sourceLinkStreamBuilder,
  @NotNull final JetSymbolsExe jetSymbolsExe,
  @NotNull final BuildProgressLogger buildLogger) {
  mySourceLinkStreamBuilder = sourceLinkStreamBuilder;
  myJetSymbolsExe = jetSymbolsExe;
  myBuildLogger = buildLogger;
}
 
Example #15
Source File: PdbFilePatcherAdapterFactoryImpl.java    From teamcity-symbol-server with Apache License 2.0 5 votes vote down vote up
public PdbFilePatcherAdapterFactoryImpl(
  @NotNull final FileUrlProvider urlProvider,
  @NotNull final BuildProgressLogger progressLogger,
  @NotNull final PdbStrExe pdbStrExe,
  @NotNull  final JetSymbolsExe jetSymbolsExe,
  @NotNull final SrcToolExe srcToolExe) {
  myUrlProvider = urlProvider;
  myProgressLogger = progressLogger;
  myPdbStrExe = pdbStrExe;
  myJetSymbolsExe = jetSymbolsExe;
  mySrcToolExe = srcToolExe;
}
 
Example #16
Source File: InterruptibleUploadProcess.java    From teamcity-deployer-plugin with Apache License 2.0 5 votes vote down vote up
public InterruptibleUploadProcess(@NotNull final FTPClient client,
                                  @NotNull final BuildProgressLogger logger,
                                  @NotNull final List<ArtifactsCollection> artifacts,
                                  final boolean isAutoType,
                                  @NotNull final String path,
                                  @NotNull AtomicReference<BuildFinishedStatus> isFinishedSuccessfully) {
  this.myClient = client;
  this.myLogger = logger;
  this.myArtifacts = artifacts;
  this.myIsAutoType = isAutoType;
  this.myPath = path;
  myFinishStatus = isFinishedSuccessfully;
}
 
Example #17
Source File: SSHExecProcessAdapter.java    From teamcity-deployer-plugin with Apache License 2.0 5 votes vote down vote up
public SSHExecProcessAdapter(@NotNull final SSHSessionProvider provider,
                             @NotNull final String commands,
                             @NotNull final String pty,
                             @NotNull final BuildProgressLogger buildLogger,
                             @NotNull final SSHProcessAdapterOptions options) {
  super(buildLogger);
  myProvider = provider;
  myCommands = commands;
  myPty = pty;
  myOptions = options;
}
 
Example #18
Source File: SSHExecProcessAdapterTest.java    From teamcity-deployer-plugin with Apache License 2.0 5 votes vote down vote up
@BeforeMethod
public void setup() {
  myContext = new Mockery();
  myContext.setImposteriser(ClassImposteriser.INSTANCE);

  mySessionProvider = myContext.mock(SSHSessionProvider.class);
  mySession = myContext.mock(Session.class);
  myChannel = myContext.mock(ChannelExec.class);
  myLogger = myContext.mock(BuildProgressLogger.class);
  myAdapter = newAdapter(myLogger);
  commonExpectations();
}
 
Example #19
Source File: SrcSrvStreamBuilder.java    From teamcity-symbol-server with Apache License 2.0 4 votes vote down vote up
public SrcSrvStreamBuilder(final FileUrlProvider urlProvider, BuildProgressLogger progressLogger) {
  myUrlProvider = urlProvider;
  myProgressLogger = progressLogger;
}
 
Example #20
Source File: TryFinallyBuildProcessImpl.java    From TeamCity.Virtual with Apache License 2.0 4 votes vote down vote up
public RunnerErrorLogger(@NotNull final BuildProgressLogger logger) {
  myLogger = logger;
}
 
Example #21
Source File: PhabLogger.java    From TeamCity-Phabricator-Plugin with MIT License 4 votes vote down vote up
public void setBuildLogger(@Nullable BuildProgressLogger buildLogger){
    this.buildProgressLogger = buildLogger;
}
 
Example #22
Source File: SSHExecProcessAdapterTest.java    From teamcity-deployer-plugin with Apache License 2.0 4 votes vote down vote up
private SSHExecProcessAdapter newAdapter(BuildProgressLogger logger) {
  SSHProcessAdapterOptions options = new SSHProcessAdapterOptions(true, false);
  return new SSHExecProcessAdapter(mySessionProvider, DEFAULT_COMMAND, null, logger, options);
}
 
Example #23
Source File: JSchBuildLogger.java    From teamcity-deployer-plugin with Apache License 2.0 4 votes vote down vote up
public JSchBuildLogger(@NotNull BuildProgressLogger buildLogger) {
  myBuildLogger = buildLogger;
}
 
Example #24
Source File: DeployerAgentUtils.java    From teamcity-deployer-plugin with Apache License 2.0 4 votes vote down vote up
public static void logBuildProblem(BuildProgressLogger logger, String message) {
  logger.logBuildProblem(BuildProblemData
          .createBuildProblem(String.valueOf(message.hashCode()),
                  DeployerRunnerConstants.BUILD_PROBLEM_TYPE,
                  "Deployment problem: " + message));
}
 
Example #25
Source File: BuildLogCommandListener.java    From teamcity-deployer-plugin with Apache License 2.0 4 votes vote down vote up
public BuildLogCommandListener(@NotNull  BuildProgressLogger logger) {
  this.myLogger = logger;
}
 
Example #26
Source File: SyncBuildProcessAdapter.java    From teamcity-deployer-plugin with Apache License 2.0 4 votes vote down vote up
public SyncBuildProcessAdapter(@NotNull final BuildProgressLogger logger) {
  myLogger = logger;
  hasFinished = false;
  statusCode = null;
}
 
Example #27
Source File: SourceLinkStreamBuilder.java    From teamcity-symbol-server with Apache License 2.0 4 votes vote down vote up
public SourceLinkStreamBuilder(final FileUrlProvider urlProvider, BuildProgressLogger progressLogger) {
  myUrlProvider = urlProvider;
  myProgressLogger = progressLogger;
}