Search in sources :

Example 11 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 12 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 13 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, 4).toLowerCase() + methodName.substring(4);
    } else if (methodName.startsWith("do")) {
        return methodName.substring(2, 3).toLowerCase() + methodName.substring(3);
    } else {
        return "";
    }
}
Also used : Exported(org.kohsuke.stapler.export.Exported)

Example 14 with Exported

use of org.kohsuke.stapler.export.Exported in project blueocean-plugin by jenkinsci.

the class PipelineRunImpl method getCommitUrl.

@Exported(name = "commitUrl")
public String getCommitUrl() {
    String commitId = getCommitId();
    if (commitId != null) {
        Container<BlueChangeSetEntry> changeSets = getChangeSet();
        BlueChangeSetEntry entry = changeSets.get(commitId);
        if (entry != null) {
            return entry.getUrl();
        }
    }
    return null;
}
Also used : BlueChangeSetEntry(io.jenkins.blueocean.rest.model.BlueChangeSetEntry) Exported(org.kohsuke.stapler.export.Exported)

Example 15 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)

Aggregations

Exported (org.kohsuke.stapler.export.Exported)20 HashSet (java.util.HashSet)5 ArrayList (java.util.ArrayList)4 Jenkins (jenkins.model.Jenkins)3 NonNull (edu.umd.cs.findbugs.annotations.NonNull)2 Executable (hudson.model.Queue.Executable)2 Cloud (hudson.slaves.Cloud)2 Method (java.lang.reflect.Method)2 ParameterizedType (java.lang.reflect.ParameterizedType)2 Type (java.lang.reflect.Type)2 GregorianCalendar (java.util.GregorianCalendar)2 ObjectMetadataAction (jenkins.scm.api.metadata.ObjectMetadataAction)2 CheckForNull (edu.umd.cs.findbugs.annotations.CheckForNull)1 ExtensionPoint (hudson.ExtensionPoint)1 PluginWrapper (hudson.PluginWrapper)1 Entry (hudson.scm.ChangeLogSet.Entry)1 AdaptedIterator (hudson.util.AdaptedIterator)1 CopyOnWriteList (hudson.util.CopyOnWriteList)1 BlueChangeSetEntry (io.jenkins.blueocean.rest.model.BlueChangeSetEntry)1 PropertyDescriptor (java.beans.PropertyDescriptor)1