예제 #1
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())));
    }
  }
예제 #2
0
  @Override
  public BuildContext call() throws InterruptedException, Exception {
    final String buildPlanKey = buildContext.getPlanKey();
    final CurrentBuildResult results = buildContext.getBuildResult();
    final Boolean runVerification = Boolean.parseBoolean(customConfiguration.get(GERRIT_RUN));

    logger.info("Run verification: " + runVerification);

    if (runVerification) {
      final List<RepositoryDefinition> repositories = buildContext.getRepositoryDefinitions();

      for (RepositoryDefinition rd : repositories) {
        if (rd.getRepository() instanceof GerritRepositoryAdapter) {
          logger.info("Updating Change Verification...");
          updateChangeVerification(rd, buildPlanKey, results);
        }
      }
    }

    return buildContext;
  }