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;
}
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();
}
};
}
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;
}
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;
}
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;
}
Aggregations