Пример #1
0
 /**
  * Programatically updates the next build number.
  *
  * <p>Much of Hudson assumes that the build number is unique and monotonic, so this method can
  * only accept a new value that's bigger than {@link #getLastBuild()} returns. Otherwise it'll be
  * no-op.
  *
  * @since 1.199 (before that, this method was package private.)
  */
 public synchronized void updateNextBuildNumber(int next) throws IOException {
   RunT lb = getLastBuild();
   if (lb != null ? next > lb.getNumber() : next > 0) {
     this.nextBuildNumber = next;
     saveNextBuildNumber();
   }
 }
Пример #2
0
  @Exported(name = "healthReport")
  public List<HealthReport> getBuildHealthReports() {
    List<HealthReport> reports = new ArrayList<HealthReport>();
    RunT lastBuild = getLastBuild();

    if (lastBuild != null && lastBuild.isBuilding()) {
      // show the previous build's report until the current one is
      // finished building.
      lastBuild = lastBuild.getPreviousBuild();
    }

    // check the cache
    if (cachedBuildHealthReportsBuildNumber != null
        && cachedBuildHealthReports != null
        && lastBuild != null
        && cachedBuildHealthReportsBuildNumber.intValue() == lastBuild.getNumber()) {
      reports.addAll(cachedBuildHealthReports);
    } else if (lastBuild != null) {
      for (HealthReportingAction healthReportingAction :
          lastBuild.getActions(HealthReportingAction.class)) {
        final HealthReport report = healthReportingAction.getBuildHealth();
        if (report != null) {
          if (report.isAggregateReport()) {
            reports.addAll(report.getAggregatedReports());
          } else {
            reports.add(report);
          }
        }
      }
      final HealthReport report = getBuildStabilityHealthReport();
      if (report != null) {
        if (report.isAggregateReport()) {
          reports.addAll(report.getAggregatedReports());
        } else {
          reports.add(report);
        }
      }

      Collections.sort(reports);

      // store the cache
      cachedBuildHealthReportsBuildNumber = lastBuild.getNumber();
      cachedBuildHealthReports = new ArrayList<HealthReport>(reports);
    }

    return reports;
  }
Пример #3
0
  /** Obtains all the {@link Run}s whose build numbers matches the given {@link RangeSet}. */
  public synchronized List<RunT> getBuilds(RangeSet rs) {
    List<RunT> builds = new LinkedList<RunT>();

    for (Range r : rs.getRanges()) {
      for (RunT b = getNearestBuild(r.start);
          b != null && b.getNumber() < r.end;
          b = b.getNextBuild()) {
        builds.add(b);
      }
    }

    return builds;
  }