コード例 #1
0
ファイル: Job.java プロジェクト: neo2buha/jenkins
 /** 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;
 }
コード例 #2
0
ファイル: Job.java プロジェクト: neo2buha/jenkins
 /** 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;
 }
コード例 #3
0
ファイル: Job.java プロジェクト: neo2buha/jenkins
 /**
  * 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;
 }
コード例 #4
0
ファイル: Job.java プロジェクト: neo2buha/jenkins
 /**
  * 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;
 }
コード例 #5
0
ファイル: Job.java プロジェクト: neo2buha/jenkins
 /**
  * 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;
 }
コード例 #6
0
ファイル: Job.java プロジェクト: neo2buha/jenkins
  /** 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;
  }
コード例 #7
0
ファイル: Job.java プロジェクト: neo2buha/jenkins
 /**
  * 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;
 }
コード例 #8
0
ファイル: Job.java プロジェクト: neo2buha/jenkins
  /**
   * 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;
  }
コード例 #9
0
ファイル: Job.java プロジェクト: neo2buha/jenkins
  @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;
  }
コード例 #10
0
ファイル: Job.java プロジェクト: neo2buha/jenkins
  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;
  }