Beispiel #1
0
 /** Returns the last completed build, if any. Otherwise null. */
 @Exported
 @QuickSilver
 public RunT getLastCompletedBuild() {
   RunT r = getLastBuild();
   while (r != null && r.isBuilding()) r = r.getPreviousBuild();
   return r;
 }
Beispiel #2
0
 /** Returns the last failed build, if any. Otherwise null. */
 @Exported
 @QuickSilver
 public RunT getLastFailedBuild() {
   RunT r = getLastBuild();
   while (r != null && (r.isBuilding() || r.getResult() != Result.FAILURE))
     r = r.getPreviousBuild();
   return r;
 }
Beispiel #3
0
 /**
  * Returns the last stable build, if any. Otherwise null.
  *
  * @see #getLastSuccessfulBuild
  */
 @Exported
 @QuickSilver
 public RunT getLastStableBuild() {
   RunT r = getLastBuild();
   while (r != null && (r.isBuilding() || r.getResult().isWorseThan(Result.SUCCESS)))
     r = r.getPreviousBuild();
   return r;
 }
Beispiel #4
0
 /**
  * Returns the last unstable build, if any. Otherwise null.
  *
  * @see #getLastSuccessfulBuild
  */
 @Exported
 @QuickSilver
 public RunT getLastUnstableBuild() {
   RunT r = getLastBuild();
   while (r != null && (r.isBuilding() || r.getResult() != Result.UNSTABLE))
     r = r.getPreviousBuild();
   return r;
 }
Beispiel #5
0
 /**
  * Returns the last build that was anything but stable, if any. Otherwise null.
  *
  * @see #getLastSuccessfulBuild
  */
 @Exported
 @QuickSilver
 public RunT getLastUnsuccessfulBuild() {
   RunT r = getLastBuild();
   while (r != null && (r.isBuilding() || r.getResult() == Result.SUCCESS))
     r = r.getPreviousBuild();
   return r;
 }
Beispiel #6
0
  /** Used as the color of the status ball for the project. */
  @Exported(visibility = 2, name = "color")
  public BallColor getIconColor() {
    RunT lastBuild = getLastBuild();
    while (lastBuild != null && lastBuild.hasntStartedYet())
      lastBuild = lastBuild.getPreviousBuild();

    if (lastBuild != null) return lastBuild.getIconColor();
    else return BallColor.GREY;
  }
Beispiel #7
0
 /**
  * Returns the last successful build, if any. Otherwise null. A successful build would include
  * either {@link Result#SUCCESS} or {@link Result#UNSTABLE}.
  *
  * @see #getLastStableBuild()
  */
 @Exported
 @QuickSilver
 public RunT getLastSuccessfulBuild() {
   RunT r = getLastBuild();
   // temporary hack till we figure out what's causing this bug
   while (r != null
       && (r.isBuilding() || r.getResult() == null || r.getResult().isWorseThan(Result.UNSTABLE)))
     r = r.getPreviousBuild();
   return r;
 }
Beispiel #8
0
  /**
   * Returns the last 'numberOfBuilds' builds with a build result >= 'threshold'
   *
   * @return a list with the builds. May be smaller than 'numberOfBuilds' or even empty if not
   *     enough builds satisfying the threshold have been found. Never null.
   */
  public List<RunT> getLastBuildsOverThreshold(int numberOfBuilds, Result threshold) {

    List<RunT> result = new ArrayList<RunT>(numberOfBuilds);

    RunT r = getLastBuild();
    while (r != null && result.size() < numberOfBuilds) {
      if (!r.isBuilding()
          && (r.getResult() != null && r.getResult().isBetterOrEqualTo(threshold))) {
        result.add(r);
      }
      r = r.getPreviousBuild();
    }

    return result;
  }
Beispiel #9
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;
  }
Beispiel #10
0
  private HealthReport getBuildStabilityHealthReport() {
    // we can give a simple view of build health from the last five builds
    int failCount = 0;
    int totalCount = 0;
    RunT i = getLastBuild();
    while (totalCount < 5 && i != null) {
      switch (i.getIconColor()) {
        case BLUE:
        case YELLOW:
          // failCount stays the same
          totalCount++;
          break;
        case RED:
          failCount++;
          totalCount++;
          break;

        default:
          // do nothing as these are inconclusive statuses
          break;
      }
      i = i.getPreviousBuild();
    }
    if (totalCount > 0) {
      int score = (int) ((100.0 * (totalCount - failCount)) / totalCount);

      Localizable description;
      if (failCount == 0) {
        description = Messages._Job_NoRecentBuildFailed();
      } else if (totalCount == failCount) {
        // this should catch the case where totalCount == 1
        // as failCount must be between 0 and totalCount
        // and we can't get here if failCount == 0
        description = Messages._Job_AllRecentBuildFailed();
      } else {
        description = Messages._Job_NOfMFailed(failCount, totalCount);
      }
      return new HealthReport(score, Messages._Job_BuildStability(description));
    }
    return null;
  }