Пример #1
0
  private String buildStatusString(CurrentBuildResult results) {
    AdministrationConfiguration config =
        administrationConfigurationManager.getAdministrationConfiguration();

    String resultsUrl =
        config.getBaseUrl() + "/browse/" + buildContext.getPlanResultKey().toString();

    List<String> errors = results.getBuildErrors();

    if (!results.getBuildState().equals(BuildState.SUCCESS)) {
      if (errors != null && errors.size() > 0) {
        return textProvider.getText(
            "processor.gerrit.messages.build.custom", Arrays.asList(errors.toString(), resultsUrl));
      } else {
        return textProvider.getText(
            "processor.gerrit.messages.build.failed", Arrays.asList(resultsUrl));
      }
    }

    return textProvider.getText(
        "processor.gerrit.messages.build.sucess", Arrays.asList(resultsUrl));
  }
Пример #2
0
  private void updateChangeVerification(
      RepositoryDefinition rd, String buildPlanKey, CurrentBuildResult results)
      throws RepositoryException {
    final GerritRepositoryAdapter gra = (GerritRepositoryAdapter) rd.getRepository();
    final String revision = buildContext.getBuildChanges().getVcsRevisionKey(rd.getId());
    final GerritService service =
        new GerritService(gra.getHostname(), gra.getPort(), gra.getGerritAuthentication());
    final GerritChangeVO change = service.getChangeByRevision(revision);

    if (change == null) {
      logger.error(textProvider.getText("repository.gerrit.messages.error.retrieve"));
      return;
    } else if (change.isMerged()) {
      logger.info(
          textProvider.getText(
              "processor.gerrit.messages.build.verified.merged", Arrays.asList(change.getId())));
      return;
    }

    if ((results.getBuildReturnCode() == 0) && results.getBuildState().equals(BuildState.SUCCESS)) {
      if (service.verifyChange(
          true,
          change.getNumber(),
          change.getCurrentPatchSet().getNumber(),
          buildStatusString(results))) {

        logger.info(textProvider.getText("processor.gerrit.messages.build.verified.pos"));
      } else {
        logger.error(
            textProvider.getText(
                "processor.gerrit.messages.build.verified.failed", Arrays.asList(change.getId())));
      }
    } else if (service.verifyChange(
        false,
        change.getNumber(),
        change.getCurrentPatchSet().getNumber(),
        buildStatusString(results))) {
      logger.info(textProvider.getText("processor.gerrit.messages.build.verified.neg"));
    } else {
      logger.error(
          textProvider.getText(
              "processor.gerrit.messages.build.verified.failed", Arrays.asList(change.getId())));
    }
  }