Search in sources :

Example 6 with Exported

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;
}
Also used : Executable(hudson.model.Queue.Executable) Exported(org.kohsuke.stapler.export.Exported)

Example 7 with Exported

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;
    }
}
Also used : Executable(hudson.model.Queue.Executable) Exported(org.kohsuke.stapler.export.Exported)

Example 8 with Exported

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;
}
Also used : Cloud(hudson.slaves.Cloud) HashSet(java.util.HashSet) Exported(org.kohsuke.stapler.export.Exported)

Example 9 with Exported

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);
}
Also used : ObjectMetadataAction(jenkins.scm.api.metadata.ObjectMetadataAction) PrimaryInstanceMetadataAction(jenkins.scm.api.metadata.PrimaryInstanceMetadataAction) Exported(org.kohsuke.stapler.export.Exported)

Example 10 with Exported

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 "";
    }
}
Also used : Exported(org.kohsuke.stapler.export.Exported)

Aggregations

Exported (org.kohsuke.stapler.export.Exported)10 Executable (hudson.model.Queue.Executable)2 HashSet (java.util.HashSet)2 ObjectMetadataAction (jenkins.scm.api.metadata.ObjectMetadataAction)2 ExtensionPoint (hudson.ExtensionPoint)1 Entry (hudson.scm.ChangeLogSet.Entry)1 Cloud (hudson.slaves.Cloud)1 AdaptedIterator (hudson.util.AdaptedIterator)1 CopyOnWriteList (hudson.util.CopyOnWriteList)1 AbstractSet (java.util.AbstractSet)1 GregorianCalendar (java.util.GregorianCalendar)1 SCMHead (jenkins.scm.api.SCMHead)1 ContributorMetadataAction (jenkins.scm.api.metadata.ContributorMetadataAction)1 PrimaryInstanceMetadataAction (jenkins.scm.api.metadata.PrimaryInstanceMetadataAction)1 ChangeRequestSCMHead (jenkins.scm.api.mixin.ChangeRequestSCMHead)1