Пример #1
0
 /**
  * @deprecated since 2008-06-15. This is only used to support backward compatibility with old
  *     URLs.
  */
 @Deprecated
 public RunT getBuild(String id) {
   for (RunT r : _getRuns().values()) {
     if (r.getId().equals(id)) return r;
   }
   return null;
 }
Пример #2
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;
 }
Пример #3
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();
   }
 }
Пример #4
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;
 }
Пример #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;
 }
Пример #6
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;
 }
Пример #7
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;
 }
Пример #8
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;
  }
Пример #9
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;
 }
Пример #10
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;
  }
Пример #11
0
 @Override
 protected void performDelete() throws IOException, InterruptedException {
   // if a build is in progress. Cancel it.
   RunT lb = getLastBuild();
   if (lb != null) {
     Executor e = lb.getExecutor();
     if (e != null) {
       e.interrupt();
       // should we block until the build is cancelled?
     }
   }
   super.performDelete();
 }
Пример #12
0
  public long getEstimatedDuration() {
    List<RunT> builds = getLastBuildsOverThreshold(3, Result.UNSTABLE);

    if (builds.isEmpty()) return -1;

    long totalDuration = 0;
    for (RunT b : builds) {
      totalDuration += b.getDuration();
    }
    if (totalDuration == 0) return -1;

    return Math.round((double) totalDuration / builds.size());
  }
Пример #13
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;
  }
Пример #14
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;
  }
Пример #15
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;
  }
Пример #16
0
 /** Returns true if the log file is still being updated. */
 public boolean isLogUpdated() {
   RunT b = getLastBuild();
   return b != null && b.isLogUpdated();
 }
Пример #17
0
 /** Returns true if a build of this project is in progress. */
 public boolean isBuilding() {
   RunT b = getLastBuild();
   return b != null && b.isBuilding();
 }