Example #1
0
  /** Update references to a renamed job in the fingerprint */
  public synchronized void rename(String oldName, String newName) throws IOException {
    boolean touched = false;
    if (original != null) {
      if (original.getName().equals(oldName)) {
        original.setName(newName);
        touched = true;
      }
    }

    if (usages != null) {
      RangeSet r = usages.get(oldName);
      if (r != null) {
        usages.put(newName, r);
        usages.remove(oldName);
        touched = true;
      }
    }

    if (touched) {
      save();
    }
  }
Example #2
0
  /**
   * Returns true if any of the builds recorded in this fingerprint is still retained.
   *
   * <p>This is used to find out old fingerprint records that can be removed without losing too much
   * information.
   */
  public synchronized boolean isAlive() {
    if (original != null && original.isAlive()) return true;

    for (Entry<String, RangeSet> e : usages.entrySet()) {
      Job j = Jenkins.getInstance().getItemByFullName(e.getKey(), Job.class);
      if (j == null) continue;

      Run firstBuild = j.getFirstBuild();
      if (firstBuild == null) continue;

      int oldest = firstBuild.getNumber();
      if (!e.getValue().isSmallerThan(oldest)) return true;
    }
    return false;
  }