提交 5450e9a8 编写于 作者: K kohsuke

[FIXED HUDSON-1569]

Added a new RSS feed type that just shows the last builds.
This techniques uses the unique ID tied to a project and keep updating the same entry by the last build.

This is a stretch of the RSS use case, and so some RSS readers do not work with this notion --- for example, the "straw" RSS reader didn't work.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@11363 71c3de6d-444a-0410-be80-ed276b4c234a
上级 cce6d8b1
......@@ -1176,7 +1176,37 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
/**
* {@link FeedAdapter} to produce feed from the summary of this build.
*/
public static final FeedAdapter<Run> FEED_ADAPTER = new FeedAdapter<Run>() {
public static final FeedAdapter<Run> FEED_ADAPTER = new DefaultFeedAdapter();
/**
* {@link FeedAdapter} to produce feeds to show one build per project.
*/
public static final FeedAdapter<Run> FEED_ADAPTER_LATEST = new DefaultFeedAdapter() {
/**
* The entry unique ID needs to be tied to a project, so that
* new builds will replace the old result.
*/
public String getEntryID(Run e) {
// can't use a meaningful year field unless we remember when the job was created.
return "tag:hudson.dev.java.net,2008:"+e.getParent().getAbsoluteUrl();
}
};
/**
* {@link BuildBadgeAction} that shows the logs are being kept.
*/
public final class KeepLogBuildBadge implements BuildBadgeAction {
public String getIconFileName() { return null; }
public String getDisplayName() { return null; }
public String getUrlName() { return null; }
public String getWhyKeepLog() { return Run.this.getWhyKeepLog(); }
}
public static final PermissionGroup PERMISSIONS = new PermissionGroup(Run.class,Messages._Run_Permissions_Title());
public static final Permission DELETE = new Permission(PERMISSIONS,"Delete", Permission.DELETE);
public static final Permission UPDATE = new Permission(PERMISSIONS,"Update", Permission.UPDATE);
private static class DefaultFeedAdapter implements FeedAdapter<Run> {
public String getEntryTitle(Run entry) {
return entry+" ("+entry.getResult()+")";
}
......@@ -1185,7 +1215,6 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
return entry.getUrl();
}
// produces a tag URL as per RFC 4151, required by Atom 1.0
public String getEntryID(Run entry) {
return "tag:" + "hudson.dev.java.net,"
+ entry.getTimestamp().get(Calendar.YEAR) + ":"
......@@ -1200,19 +1229,5 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
public Calendar getEntryTimestamp(Run entry) {
return entry.getTimestamp();
}
};
/**
* {@link BuildBadgeAction} that shows the logs are being kept.
*/
public final class KeepLogBuildBadge implements BuildBadgeAction {
public String getIconFileName() { return null; }
public String getDisplayName() { return null; }
public String getUrlName() { return null; }
public String getWhyKeepLog() { return Run.this.getWhyKeepLog(); }
}
public static final PermissionGroup PERMISSIONS = new PermissionGroup(Run.class,Messages._Run_Permissions_Title());
public static final Permission DELETE = new Permission(PERMISSIONS,"Delete", Permission.DELETE);
public static final Permission UPDATE = new Permission(PERMISSIONS,"Update", Permission.UPDATE);
}
......@@ -282,6 +282,19 @@ public abstract class View extends AbstractModelObject implements AccessControll
runs.newBuilds(), Run.FEED_ADAPTER, req, rsp );
}
public void doRssLatest( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
List<Run> lastBuilds = new ArrayList<Run>();
for (TopLevelItem item : getItems()) {
if (item instanceof Job) {
Job job = (Job) item;
Run lb = job.getLastBuild();
if(lb!=null) lastBuilds.add(lb);
}
}
RSS.forwardToRss(getDisplayName()+" last builds only", getUrl(),
lastBuilds, Run.FEED_ADAPTER_LATEST, req, rsp );
}
public static final Comparator<View> SORTER = new Comparator<View>() {
public int compare(View lhs, View rhs) {
return lhs.getViewName().compareTo(rhs.getViewName());
......
<j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<div align="right" style="margin:1em">
<a href="${rootURL}/legend">${%Legend}</a>
<st:nbsp/><st:nbsp/><st:nbsp/><st:nbsp/>
<a href="rssAll"><img src="${imagesURL}/atom.gif" border="0"/> ${%for all}</a>
<st:nbsp/><st:nbsp/><st:nbsp/><st:nbsp/>
<a href="rssFailed"><img src="${imagesURL}/atom.gif" border="0"/> ${%for failures}</a>
<span style="padding-left:1em">
<a href="rssAll"><img src="${imagesURL}/atom.gif" border="0"/> ${%for all}</a>
</span>
<span style="padding-left:1em">
<a href="rssFailed"><img src="${imagesURL}/atom.gif" border="0"/> ${%for failures}</a>
</span>
<span style="padding-left:1em">
<a href="rssLatest"><img src="${imagesURL}/atom.gif" border="0"/> ${%for just last builds}</a>
</span>
</div>
</j:jelly>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册