use of org.kohsuke.stapler.export.Exported in project hudson-2.x by hudson.
the class Executor method getProgress.
/**
* Returns the progress of the current build in the number between 0-100.
*
* @return -1
* if it's impossible to estimate the progress.
*/
@Exported
public int getProgress() {
Queue.Executable e = executable;
if (e == null)
return -1;
long d = Executables.getEstimatedDurationFor(e);
if (d < 0)
return -1;
int num = (int) (getElapsedTime() * 100 / d);
if (num >= 100)
num = 99;
return num;
}
use of org.kohsuke.stapler.export.Exported in project hudson-2.x by hudson.
the class Executor method isLikelyStuck.
/**
* Returns true if the current build is likely stuck.
*
* <p>
* This is a heuristics based approach, but if the build is suspiciously taking for a long time,
* this method returns true.
*/
@Exported
public boolean isLikelyStuck() {
Queue.Executable e = executable;
if (e == null)
return false;
long elapsed = getElapsedTime();
long d = Executables.getEstimatedDurationFor(e);
if (d >= 0) {
// if it's taking 10 times longer than ETA, consider it stuck
return d * 10 < elapsed;
} else {
// if no ETA is available, a build taking longer than a day is considered stuck
return TimeUnit2.MILLISECONDS.toHours(elapsed) > 24;
}
}
use of org.kohsuke.stapler.export.Exported in project hudson-2.x by hudson.
the class Label method getClouds.
/**
* Gets all {@link Cloud}s that can launch for this label.
*/
@Exported
public Set<Cloud> getClouds() {
if (clouds == null) {
Set<Cloud> r = new HashSet<Cloud>();
Hudson h = Hudson.getInstance();
for (Cloud c : h.clouds) {
if (c.canProvision(this))
r.add(c);
}
clouds = Collections.unmodifiableSet(r);
}
return clouds;
}
use of org.kohsuke.stapler.export.Exported in project blueocean-plugin by jenkinsci.
the class BranchImpl method getBranch.
@Exported(name = BRANCH, inline = true)
public Branch getBranch() {
ObjectMetadataAction om = job.getAction(ObjectMetadataAction.class);
PrimaryInstanceMetadataAction pima = job.getAction(PrimaryInstanceMetadataAction.class);
String url = om != null && om.getObjectUrl() != null ? om.getObjectUrl() : null;
return new Branch(url, pima != null);
}
use of org.kohsuke.stapler.export.Exported in project blueocean-plugin by jenkinsci.
the class Links method getPathFromMethodName.
private String getPathFromMethodName(Method m) {
String methodName = m.getName();
Exported exportedAnn = m.getAnnotation(Exported.class);
if (exportedAnn != null && !exportedAnn.name().trim().isEmpty())
return exportedAnn.name();
if (methodName.startsWith("get")) {
return methodName.substring(3).toLowerCase();
} else if (methodName.startsWith("do")) {
return methodName.substring(2).toLowerCase();
} else {
return "";
}
}
Aggregations