diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index 9df9848cc7..f20ce98d75 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -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"); } diff --git a/core/src/main/java/hudson/model/Hudson.java b/core/src/main/java/hudson/model/Hudson.java index ea360dd628..e7f612a7eb 100644 --- a/core/src/main/java/hudson/model/Hudson.java +++ b/core/src/main/java/hudson/model/Hudson.java @@ -757,7 +757,20 @@ public final class Hudson extends View implements ItemGroup, 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() { diff --git a/core/src/main/resources/hudson/model/View/cc.xml.jelly b/core/src/main/resources/hudson/model/View/cc.xml.jelly new file mode 100644 index 0000000000..29b6108e08 --- /dev/null +++ b/core/src/main/resources/hudson/model/View/cc.xml.jelly @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + \ No newline at end of file