Search in sources :

Example 1 with Exported

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

the class BranchImpl method getPullRequest.

@Exported(name = PULL_REQUEST, inline = true)
public PullRequest getPullRequest() {
    // TODO probably want to be using SCMHeadCategory instances to categorize them instead of hard-coding for PRs
    SCMHead head = SCMHead.HeadByItem.findHead(job);
    if (head instanceof ChangeRequestSCMHead) {
        ChangeRequestSCMHead cr = (ChangeRequestSCMHead) head;
        ObjectMetadataAction om = job.getAction(ObjectMetadataAction.class);
        ContributorMetadataAction cm = job.getAction(ContributorMetadataAction.class);
        return new PullRequest(cr.getId(), om != null ? om.getObjectUrl() : null, om != null ? om.getObjectDisplayName() : null, cm != null ? cm.getContributor() : null);
    }
    return null;
}
Also used : ChangeRequestSCMHead(jenkins.scm.api.mixin.ChangeRequestSCMHead) SCMHead(jenkins.scm.api.SCMHead) ChangeRequestSCMHead(jenkins.scm.api.mixin.ChangeRequestSCMHead) ObjectMetadataAction(jenkins.scm.api.metadata.ObjectMetadataAction) ContributorMetadataAction(jenkins.scm.api.metadata.ContributorMetadataAction) Exported(org.kohsuke.stapler.export.Exported)

Example 2 with Exported

use of org.kohsuke.stapler.export.Exported in project hudson-2.x by hudson.

the class AbstractBuild method getCulprits.

/**
 * List of users who committed a change since the last non-broken build till now.
 *
 * <p>
 * This list at least always include people who made changes in this build, but
 * if the previous build was a failure it also includes the culprit list from there.
 * Culprits of unstable build are also included
 * see <a href="http://issues.hudson-ci.org/browse/HUDSON-4617">HUDSON-4617</a> for details
 * @return
 *      can be empty but never null.
 */
@Exported
public Set<User> getCulprits() {
    if (culprits == null) {
        Set<User> r = new HashSet<User>();
        R p = getPreviousCompletedBuild();
        if (p != null && isBuilding()) {
            Result pr = p.getResult();
            if (pr != null && pr.isWorseOrEqualTo(Result.UNSTABLE)) {
                // we are still building, so this is just the current latest information,
                // but we seems to be failing so far, so inherit culprits from the previous build.
                // isBuilding() check is to avoid recursion when loading data from old Hudson, which doesn't record
                // this information
                r.addAll(p.getCulprits());
            }
        }
        for (Entry e : getChangeSet()) r.add(e.getAuthor());
        if (upstreamCulprits) {
            // If we have dependencies since the last successful build, add their authors to our list
            R previousBuild = getPreviousSuccessfulBuild();
            if (previousBuild != null) {
                Map<AbstractProject, AbstractBuild.DependencyChange> depmap = getDependencyChanges(previousBuild);
                for (AbstractBuild.DependencyChange dep : depmap.values()) {
                    for (AbstractBuild<?, ?> b : dep.getBuilds()) {
                        for (Entry entry : b.getChangeSet()) {
                            r.add(entry.getAuthor());
                        }
                    }
                }
            }
        }
        return r;
    }
    return new AbstractSet<User>() {

        public Iterator<User> iterator() {
            return new AdaptedIterator<String, User>(culprits.iterator()) {

                protected User adapt(String id) {
                    return User.get(id);
                }
            };
        }

        public int size() {
            return culprits.size();
        }
    };
}
Also used : AbstractSet(java.util.AbstractSet) AdaptedIterator(hudson.util.AdaptedIterator) Entry(hudson.scm.ChangeLogSet.Entry) HashSet(java.util.HashSet) Exported(org.kohsuke.stapler.export.Exported)

Example 3 with Exported

use of org.kohsuke.stapler.export.Exported in project hudson-2.x by hudson.

the class Queue method getItems.

/**
 * Gets a snapshot of items in the queue.
 *
 * Generally speaking the array is sorted such that the items that are most likely built sooner are
 * at the end.
 */
@Exported(inline = true)
public synchronized Item[] getItems() {
    Item[] r = new Item[waitingList.size() + blockedProjects.size() + buildables.size() + pendings.size()];
    waitingList.toArray(r);
    int idx = waitingList.size();
    for (BlockedItem p : blockedProjects.values()) r[idx++] = p;
    for (BuildableItem p : reverse(buildables.values())) r[idx++] = p;
    for (BuildableItem p : reverse(pendings.values())) r[idx++] = p;
    return r;
}
Also used : ExtensionPoint(hudson.ExtensionPoint) Exported(org.kohsuke.stapler.export.Exported)

Example 4 with Exported

use of org.kohsuke.stapler.export.Exported in project hudson-2.x by hudson.

the class Run method getTimestamp.

/**
 * When the build is scheduled.
 */
@Exported
public Calendar getTimestamp() {
    GregorianCalendar c = new GregorianCalendar();
    c.setTimeInMillis(timestamp);
    return c;
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Exported(org.kohsuke.stapler.export.Exported)

Example 5 with Exported

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

the class ExportedDescribableParameter method getCollectionTypes.

/**
 * Java types allowed if this is a collection
 * See {@link DescribableParameter#getType()} and {@link ParameterType#getActualType()}
 */
@Exported
public List<String> getCollectionTypes() {
    List<String> collectionTypes = new ArrayList<>();
    Type typ = param.getType().getActualType();
    if (typ instanceof ParameterizedType) {
        Type[] typeArgs = ((ParameterizedType) typ).getActualTypeArguments();
        for (Type ptyp : typeArgs) {
            if (ptyp instanceof Class<?>) {
                collectionTypes.add(((Class<?>) ptyp).getName());
            }
        }
    }
    return collectionTypes;
}
Also used : ParameterizedType(java.lang.reflect.ParameterizedType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) ParameterType(org.jenkinsci.plugins.structs.describable.ParameterType) ArrayList(java.util.ArrayList) Exported(org.kohsuke.stapler.export.Exported)

Aggregations

Exported (org.kohsuke.stapler.export.Exported)14 HashSet (java.util.HashSet)3 Executable (hudson.model.Queue.Executable)2 ParameterizedType (java.lang.reflect.ParameterizedType)2 Type (java.lang.reflect.Type)2 ArrayList (java.util.ArrayList)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 BlueChangeSetEntry (io.jenkins.blueocean.rest.model.BlueChangeSetEntry)1 PropertyDescriptor (java.beans.PropertyDescriptor)1 GenericArrayType (java.lang.reflect.GenericArrayType)1 Method (java.lang.reflect.Method)1 WildcardType (java.lang.reflect.WildcardType)1 AbstractSet (java.util.AbstractSet)1 GregorianCalendar (java.util.GregorianCalendar)1 SCMHead (jenkins.scm.api.SCMHead)1