private String getUrl(Run n) { if(n ==null) return null; else { return head+n.getNumber()+rest; } } }
@Override protected final int getNumberOf(R r) { return r.getNumber(); }
public String getKey(Run record) { return String.valueOf(record.getNumber()); }
public final @Nonnull String getSearchUrl() { return getNumber()+"/"; }
/** * Produces an identifier for this run unique in the system. * @return the {@link Job#getFullName}, then {@code #}, then {@link #getNumber} * @see #fromExternalizableId */ public @Nonnull String getExternalizableId() { return project.getFullName() + "#" + getNumber(); }
protected static long getEntryId(@Nonnull Object entry) { if (entry instanceof Queue.Item) { return ((Queue.Item) entry).getId(); } else if (entry instanceof Run) { Run run = (Run) entry; return (Long.MIN_VALUE + run.getNumber()); } else if (entry instanceof Number) { // Used for testing purposes because of JENKINS-30899 and JENKINS-30909 return (Long.MIN_VALUE + ((Number) entry).longValue()); } else { return Run.QUEUE_ID_UNKNOWN; } } }
/** * Obtains the absolute URL to this build. * * @deprecated * This method shall <b>NEVER</b> be used during HTML page rendering, as it's too easy for * misconfiguration to break this value, with network set up like Apache reverse proxy. * This method is only intended for the remote API clients who cannot resolve relative references. */ @Exported(visibility=2,name="url") @Deprecated public final @Nonnull String getAbsoluteUrl() { return project.getAbsoluteUrl()+getNumber()+'/'; }
/** * Returns true if {@link BuildPtr} points to the given run. */ public boolean is(Run r) { return r.getNumber()==number && r.getParent().getFullName().equals(name); }
/** * Add a <em>new</em> build to the map. * Do not use when loading existing builds (use {@link #put(Integer, Object)}). */ @Override public R put(R r) { // Defense against JENKINS-23152 and its ilk. File rootDir = r.getRootDir(); if (rootDir.isDirectory()) { throw new IllegalStateException("JENKINS-23152: " + rootDir + " already existed; will not overwrite with " + r); } if (!r.getClass().getName().equals("hudson.matrix.MatrixRun")) { // JENKINS-26739: grandfathered in proposeNewNumber(r.getNumber()); } rootDir.mkdirs(); return super._put(r); }
/** * 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; }
/** * Returns true if this cause points to the specified build. */ public boolean pointsTo(Run<?,?> r) { return r.getNumber()==upstreamBuild && pointsTo(r.getParent()); }
@Override public String toString(Object object) { Run<?,?> run = (Run<?,?>) object; return run.getParent().getFullName() + "#" + run.getNumber(); } });
public BuildPtr(Run run) { this( run.getParent().getFullName(), run.getNumber() ); }
/** * Adds a usage reference to the build. * @param b {@link Run} to be referenced in {@link #usages} * @since 1.577 */ public synchronized void addFor(@Nonnull Run b) throws IOException { add(b.getParent().getFullName(), b.getNumber()); }
/** * See if the new build matches any of the peephole permalink. */ @Override public void onCompleted(Run<?,?> run, @Nonnull TaskListener listener) { Job<?, ?> j = run.getParent(); for (PeepholePermalink pp : Util.filter(j.getPermalinks(), PeepholePermalink.class)) { if (pp.apply(run)) { Run<?, ?> cur = pp.resolve(j); if (cur==null || cur.getNumber()<run.getNumber()) { if (LOGGER.isLoggable(Level.FINE)) LOGGER.fine("Updating "+pp.getPermalinkFile(j).getName()+" permalink to completed "+run.getNumber()); pp.updateCache(j,run); } } } } }
/** * 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(); } }
/** * If any of the peephole permalink points to the build to be deleted, update it to point to the new location. */ @Override public void onDeleted(Run run) { Job<?, ?> j = run.getParent(); for (PeepholePermalink pp : Util.filter(j.getPermalinks(), PeepholePermalink.class)) { if (pp.resolve(j)==run) { Run<?,?> r = pp.find(run.getPreviousBuild()); if (LOGGER.isLoggable(Level.FINE)) LOGGER.fine("Updating "+pp.getPermalinkFile(j).getName()+" permalink from deleted "+run.getNumber()+" to "+(r == null ? -1 : r.getNumber())); pp.updateCache(j,r); } } }
public UpstreamCause(Run<?, ?> up) { upstreamBuild = up.getNumber(); upstreamProject = up.getParent().getFullName(); upstreamUrl = up.getParent().getUrl(); upstreamCauses = new ArrayList<Cause>(); Set<String> traversed = new HashSet<String>(); for (Cause c : up.getCauses()) { upstreamCauses.add(trim(c, MAX_DEPTH, traversed)); } }
@Override public String getShortDescription() { Executor e = build.getExecutor(); String eta = ""; if (e != null) { eta = Messages.BlockedBecauseOfBuildInProgress_ETA(e.getEstimatedRemainingTime()); } int lbn = build.getNumber(); return Messages.BlockedBecauseOfBuildInProgress_shortDescription(lbn, eta); }