2008-01-28

Hiding .svn directories in the CruiseControl Status Page

If you've got a CruiseControl installation and you're anything like me, you won't be happy unless your entire CruiseControl setup is revision-controlled and lives in your subversion repository. (Here's a good article on how to get you started and auto-update CruiseControl's config.xml using bootstrappers.)

The Problem

There's a small problem, however, with your entire CC configuration living in source control, as you've realized if you've ever pulled up the status page and seen this:

Old and Busted

The status page blindly slurps up every directory under /cruisecontrol/logs, including the .svn directory. Whoops. I can see a few options:

  • Don't put the logs directory in source control, and remember to recreate it the next time we rebuild the machine.
  • Do an svn export to deploy the CruiseControl setup on our build machine.
  • Patch the status page code to not show the ".svn" entry.

I went with option 3.

The Patch (For CruiseControl 2.7.1, Binary Distribution)

Under $CC_INSTALL/webapps/cruisecontrol/, open the file index.jsp. It's a simple 4-line patch. Near the top, we will add 3 lines:

   final Date now = new Date();
   final String dateNow = dateTimeFormat.format(now);
%>
+<%
+  final java.util.List ignoredLogDirs = Arrays.asList(new String[] {".svn", "CVS"});
+%>
<%
   class SortableStatus implements Comparable {

 

Then, scroll down to line 460 and change it:

         else {
           String[] projectDirs = logDir.list(new java.io.FilenameFilter() {
             public boolean accept(File dir, String name) {
-              return (new File(dir, name).isDirectory());
+              return (new File(dir, name).isDirectory() && !ignoredLogDirs.contains(name));
             }
           });

 

Save, refresh the page to test your changes, and safely commit the new version:

New Hotness

Quick Note

Now, if we wanted to be really fancy and do the 100% solution, we'd fix the same thing on the individual project pages, in the left-hand panel where a drop-down menu allows navigating to other projects. To do this, however, we'd need to look at the ProjectNavigationTag source, and it's not in the binary CruiseControl distribution, so that's out of scope for today.

No comments: