提交 afad4ce9 编写于 作者: K kohsuke

generate CruiseControl compatible XML report to support cctray clients.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@5860 71c3de6d-444a-0410-be80-ed276b4c234a
上级 e419a0c7
......@@ -690,5 +690,27 @@ public class Functions {
return Math.max(5,LINE_END.split(s).length);
}
/**
* Converts the Hudson build status to CruiseControl build status,
* which is either Success, Failure, Exception, or Unknown.
*/
public static String toCCStatus(Item i) {
if (i instanceof Job) {
Job j = (Job) i;
switch (j.getIconColor().noAnime()) {
case ABORTED:
case RED:
case YELLOW:
return "Failure";
case BLUE:
return "Success";
case DISABLED:
case GREY:
return "Unknown";
}
}
return "Unknown";
}
private static final Pattern LINE_END = Pattern.compile("\r?\n");
}
......@@ -757,7 +757,20 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node
*/
public String getRootUrl() {
// for compatibility. the actual data is stored in Mailer
return Mailer.DESCRIPTOR.getUrl();
String url = Mailer.DESCRIPTOR.getUrl();
if(url!=null) return url;
StaplerRequest req = Stapler.getCurrentRequest();
if(req!=null) {
StringBuilder buf = new StringBuilder();
buf.append("http://");
buf.append(req.getServerName());
if(req.getServerPort()!=80)
buf.append(':').append(req.getServerPort());
buf.append(req.getContextPath()).append('/');
return buf.toString();
}
return null;
}
public File getRootDir() {
......
<!--
Generate status XML compatible with CruiseControl.
See http://confluence.public.thoughtworks.org/display/CI/Multiple+Project+Summary+Reporting+Standard
-->
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<st:contentType value="text/xml;charset=UTF-8" />
<j:new var="h" className="hudson.Functions" />
<Projects>
<j:forEach var="p" items="${it.items}">
<j:set var="lb" value="${p.lastBuild}"/>
<j:if test="${lb!=null}">
<Project name="${p.displayName}"
activity="${h.ifThenElse(p.isBuilding(),'Building','Sleeping')}"
lastBuildStatus="${h.toCCStatus(p)}"
lastBuildLabel="${lb.number}"
lastBuildTime="${lb.timestampString2}"
webUrl="${app.rootUrl}${p.url}"
/>
</j:if>
</j:forEach>
</Projects>
</j:jelly>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册