public String getEntryUrl(Run entry) { return entry.getUrl(); }
public String getEntryUrl(FeedItem item) { return item.getBuild().getUrl() + "changes#detail" + item.idx; }
public static String encodeTo(Run r) { return encodeTo('/'+r.getUrl(),r.getDisplayName()); }
public TimelineEventList doData(StaplerRequest req, @QueryParameter long min, @QueryParameter long max) throws IOException { TimelineEventList result = new TimelineEventList(); for (Run r : builds.byTimestamp(min,max)) { Event e = new Event(); e.start = new Date(r.getStartTimeInMillis()); e.end = new Date(r.getStartTimeInMillis()+r.getDuration()); // due to SimileAjax.HTML.deEntify (in simile-ajax-bundle.js), "<" are transformed back to "<", but not the "<"; // to protect against XSS e.title = Util.escape(r.getFullDisplayName()).replace("<", "<"); // what to put in the description? // e.description = "Longish description of event "+r.getFullDisplayName(); // e.durationEvent = true; e.link = req.getContextPath()+'/'+r.getUrl(); BallColor c = r.getIconColor(); e.color = String.format("#%06X",c.getBaseColor().darker().getRGB()&0xFFFFFF); e.classname = "event-"+c.noAnime().toString()+" " + (c.isAnimated()?"animated":""); result.add(e); } return result; }
@Override public void buildEnvironmentFor(Run r, EnvVars env, TaskListener listener) throws IOException, InterruptedException { Computer c = Computer.currentComputer(); if (c!=null){ EnvVars compEnv = c.getEnvironment().overrideAll(env); env.putAll(compEnv); } env.put("BUILD_DISPLAY_NAME",r.getDisplayName()); Jenkins j = Jenkins.getInstance(); String rootUrl = j.getRootUrl(); if(rootUrl!=null) { env.put("BUILD_URL", rootUrl+r.getUrl()); } }
public void execute(StaplerResponse response) { if (build != null) { try { response.sendRedirect2(Jenkins.getInstance().getRootUrl() + build.getUrl()); } catch (IOException e) { try { response.sendRedirect2(Jenkins.getInstance().getRootUrl() + build.getBuildStatusUrl()); } catch (IOException e1) { throw HttpResponses.error(500, "Failed to redirect to build page"); } } } } }
/** * Exposes the name/value as an environment variable. */ @Override public void buildEnvironment(Run<?,?> build, EnvVars env) { Run run = getRun(); String value = (null == run) ? "UNKNOWN" : Jenkins.getInstance().getRootUrl() + run.getUrl(); env.put(name, value); env.put(name + ".jobName", getJobName()); // undocumented, left for backward compatibility env.put(name + "_JOBNAME", getJobName()); // prefer this version env.put(name + ".number" , getNumber ()); // same as above env.put(name + "_NUMBER" , getNumber ()); // if run is null, default to the standard '#1' display name format env.put(name + "_NAME", (null == run) ? "#" + getNumber() : run.getDisplayName()); // since 1.504 String buildResult = (null == run || null == run.getResult()) ? "UNKNOWN" : run.getResult().toString(); env.put(name + "_RESULT", buildResult); // since 1.517 env.put(name.toUpperCase(Locale.ENGLISH),value); // backward compatibility pre 1.345 }
@Override protected void calculate(Run<?,?> build, JSONObject element) { BallColor iconColor = build.getIconColor(); element.put("iconColorOrdinal", iconColor.ordinal()); element.put("iconColorDescription", iconColor.getDescription()); element.put("url", build.getUrl()); element.put("buildStatusUrl", build.getBuildStatusUrl()); element.put("parentUrl", build.getParent().getUrl()); element.put("parentFullDisplayName", Functions.breakableString(Functions.escape(build.getParent().getFullDisplayName()))); element.put("displayName", build.getDisplayName()); element.put("timestampString", build.getTimestampString()); element.put("timestampString2", build.getTimestampString2()); element.put("timestampString3", Util.XS_DATETIME_FORMATTER.format(new Date(build.getStartTimeInMillis()))); Run.Summary buildStatusSummary = build.getBuildStatusSummary(); element.put("buildStatusSummaryWorse", buildStatusSummary.isWorse); element.put("buildStatusSummaryMessage", buildStatusSummary.message); }
private String getNote(Run<?, ?> build, TaskListener listener) { String message; if (this.replaceSuccessNote && build.getResult() == Result.SUCCESS) { message = replaceMacros(build, listener, this.getSuccessNoteText()); } else if (this.replaceAbortNote && build.getResult() == Result.ABORTED) { message = replaceMacros(build, listener, this.getAbortNoteText()); } else if (this.replaceUnstableNote && build.getResult() == Result.UNSTABLE) { message = replaceMacros(build, listener, this.getUnstableNoteText()); } else if (this.replaceFailureNote && build.getResult() == Result.FAILURE) { message = replaceMacros(build, listener, this.getFailureNoteText()); } else { String icon = getResultIcon(build.getResult()); String buildUrl = Jenkins.getInstance().getRootUrl() + build.getUrl(); message = MessageFormat.format("{0} Jenkins Build {1}\n\nResults available at: [Jenkins [{2} #{3}]]({4})", icon, build.getResult().toString(), build.getParent().getDisplayName(), build.getNumber(), buildUrl); } return message; } }
/** * Calculate the build URL of a build of default type. This will be overriden by specific build types. * * @return the build URL of a build of default type */ public String calculateBuildUrl(String publishedURL) { return publishedURL + "/" + build.getUrl(); }
@Override public String getUrl() { // TODO ideally this would be found via FlowExecution.owner.executable, but how do we check for something with a URL? There is no marker interface for it: JENKINS-26091 Run<?,?> r = runForDisplay(); return r != null ? r.getUrl() : ""; }
@Override public String getUrl() { // TODO ideally this would be found via FlowExecution.owner.executable, but how do we check for something with a URL? There is no marker interface for it: JENKINS-26091 Run<?,?> r = runForDisplay(); return r != null ? r.getUrl() : ""; }
@Override public String getUrl() { // TODO ideally this would be found via FlowExecution.owner.executable, but how do we check for something with a URL? There is no marker interface for it: JENKINS-26091 Run<?,?> r = runForDisplay(); return r != null ? r.getUrl() : ""; }
@Override public synchronized void onCompleted(Run run, @Nonnull TaskListener listener) { runsToPoll.remove(run); pollRun(run); logger.info("onCompleted " + run.getUrl()); super.onCompleted(run, listener); }
@Override public synchronized void onDeleted(Run run) { runsToPoll.remove(run); pollRun(run); logger.info("onDeleted " + run.getUrl()); super.onDeleted(run); // TODO should we remove the OpenShift Build too? }
void onStarted(BitbucketCause cause, Run<?, ?> build) { if (cause == null) { return; } try { build.setDescription(cause.getShortDescription()); String buildUrl = getBuildUrl(build.getUrl()); repository.setBuildStatus(cause, BuildState.INPROGRESS, buildUrl); } catch (IOException e) { logger.log(Level.SEVERE, "Can't update build description", e); } }
/** * Exposes the name/value as an environment variable. */ @Override public void buildEnvVars(AbstractBuild<?, ?> build, EnvVars env) { String value = Hudson.getInstance().getRootUrl() + getRun().getUrl(); env.put(name, value); env.put(name.toUpperCase(Locale.ENGLISH), value); // backward compatibility pre 1.345 }
/** * Exposes the name/value as an environment variable. */ @Override public void buildEnvVars(AbstractBuild<?,?> build, EnvVars env) { String value = Hudson.getInstance().getRootUrl() + getRun().getUrl(); env.put(name, value); env.put(name.toUpperCase(Locale.ENGLISH),value); // backward compatibility pre 1.345 }
/** * Exposes the name/value as an environment variable. */ @Override public void buildEnvVars(AbstractBuild<?,?> build, EnvVars env) { String value = Hudson.getInstance().getRootUrl() + getRun().getUrl(); env.put(name, value); env.put(name.toUpperCase(Locale.ENGLISH),value); // backward compatibility pre 1.345 }
public BuildInfo(Run run) { this.timestamp = run.getTimestamp(); this.url = "/" + run.getUrl(); this.name = run.getFullDisplayName(); this.result = run.isBuilding() ? "Building" : run.getResult().toString(); }