Exemplo n.º 1
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;
  }
Exemplo n.º 2
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;
  }