Exemplo n.º 1
0
 @Override
 public void execute(JobExecutionContext context) throws JobExecutionException {
   VerigreenLogger.get()
       .log(
           getClass().getName(),
           RuntimeUtils.getCurrentMethodName(),
           String.format(
               "Branch Cleaner is running, deleting branches %s days old...",
               VerigreenNeededLogic.VerigreenMap.get("branchCleanDaysThreashold")));
   deleteBranches();
 }
Exemplo n.º 2
0
  @Override
  public void execute(JobExecutionContext arg0) throws JobExecutionException {

    VerigreenLogger.get()
        .log(
            getClass().getName(),
            RuntimeUtils.getCurrentMethodName(),
            String.format(
                "Cache Cleaner is running, deleting items %s days old...",
                VerigreenNeededLogic.VerigreenMap.get("daysThreashold")));
    deleteCommitItems();
  }
Exemplo n.º 3
0
  protected void send(String subject, String messageText, String[] recipients, String signature) {

    try {
      EmailUtils.send(
          subject, messageText, recipients, "*****@*****.**", _mailServer, signature);
    } catch (MessagingException ex) {
      VerigreenLogger.get()
          .error(
              getClass().getName(),
              RuntimeUtils.getCurrentMethodName(),
              String.format(
                  "Failed sending email message [%s] to the following recipients: %s",
                  messageText, Arrays.toString(recipients)),
              ex);
    }
  }
Exemplo n.º 4
0
  private List<String> branchesToBeDelete(List<String> branchesList) {
    List<String> result = new ArrayList<>();
    Repository repo = null;
    Map<String, List<String>> branchesMap = new HashMap<>();
    for (String branch : branchesList) {
      List<String> values = null;
      if (!branchesMap.containsKey(branch.subSequence(0, 10))) {
        values = new ArrayList<>();
        values.add(branch);
        branchesMap.put(branch.subSequence(0, 10).toString(), values);
      } else if (!branchesMap.get(branch.subSequence(0, 10)).contains(branch)) {
        values = branchesMap.get(branch.subSequence(0, 10));
        values.add(branch);
        branchesMap.put(branch.subSequence(0, 10).toString(), values);
      }
    }
    List<CommitItem> allBranches = CollectorApi.getCommitItemContainer().getAll();
    for (CommitItem branch : allBranches) {
      if (branchesMap.containsKey(branch.getBranchDescriptor().getNewBranch().subSequence(0, 10))) {
        branchesMap.remove(branch.getBranchDescriptor().getNewBranch().subSequence(0, 10));
      }
    }
    for (String key : branchesMap.keySet()) {
      result.addAll(branchesMap.get(key));
    }

    try {
      repo =
          new FileRepository(VerigreenNeededLogic.properties.getProperty("git.repositoryLocation"));
      if (result.contains(repo.getBranch())) {
        _jgit.checkout(VerigreenNeededLogic.VerigreenMap.get("_protectedBranches"), false, false);
      }
    } catch (IOException e) {
      VerigreenLogger.get()
          .error(
              getClass().getName(),
              RuntimeUtils.getCurrentMethodName(),
              String.format(
                  "Failed creating git repository for path [%s]",
                  VerigreenNeededLogic.properties.getProperty("git.repositoryLocation")),
              e);
    }

    return result;
  }
Exemplo n.º 5
0
  public static CreateBranchRequest getCreateBranchRequest(BranchDescriptor branchDescriptor) {

    return RuntimeUtils.cast(
        getBean("createBranchRequest", CollectorApi.getCollectorAddress(), branchDescriptor));
  }