How Do I…?
One of the common issues with CruiseControl.Net is it can be challenging to configure it – now of it’s parts have any configuration tools (except CCTray). Looking at some of the other CI tools out there (e.g. Cruise, TeamCity, etc.), it is obvious they also have picked up on this. Not only that, but they have done something about it, so much so, that there are people who are changing to these products just because they are easy to configure!
So, this is an issue for CruiseControl.Net, and not something we can easily ignore.
The Bigger Picture
One of the reasons why CruiseControl.Net doesn’t have any configuration tools is it’s flexibility. There is a huge range of possibilities, plus it is pretty easy to write extensions to CruiseControl.Net. So, how do we build a tool (or set of tools) that can cover all the possibilities?
Additionally, there is not just one part of CruiseControl.Net to configure, but multiple. Most people know about ccnet.config, fewer know about dashboard.config and even fewer know about ccnet.exe.config, ccservice.exe.config and web.config. So, the first question is why so many? And can we remove any?
But before I answer this question, what are these files?
First ccnet.config contains the project and queue configurations (and security from 1.5). This is the “main” configuration for CruiseControl.Net, in that it defines the build process. There is no way we can not have this configuration file.
Dashboard.config provides similar functionality, but for the web dashboard. It defines the servers to monitor and the plug-ins to use. Again, it is critical to the system, otherwise the dashboard would be empty! However, there are a few quirks around this file, especially around the way it is cached.
The other three files (ccnet.exe.config, ccservice.exe.config and web.config) are the .NET configuration files. They contain the settings required for things like .NET Remoting, log (i.e. Log4Net settings), a few miscellaneous settings (like where to find the actual config file, etc.) Now, we could remove these files, but it would probably break some things! Therefore we won’t be looking at removing them, although we may try to tidy them up a bit.
Now that I’ve covered the bigger picture, let’s look at improving one (little) area.
Dashboard Plug-ins
The dashboard works on a plug-in model, most of the information that is available comes from plug-ins. If the administrator doesn’t want the users to see some information, they can remove that plug-in. Likewise, new plug-ins can be added to provide additional functionality. Some plug-ins are hard-coded (e.g. the interfaces for CCTray, etc.), but otherwise the administrator has a lot of control of what is included.
To add or remove plug-ins, the administrator needs to modify dashboard.config (in the dashboard folder) and then start IIS. Additionally, if they want to add a new plug-in, they need to copy all the required files (e.g. templates, XSL-T files, etc.) into the right place. This makes adding a new plug-in a fragile process, as there is no guarantee the administrator will get everything right.
Now, in my previous job, there was the concept of a package. A package contained all the necessary files, plus a manifest that described how the files were to be used. Our application would open the package, read the manifest and then correctly deploy the files (at least it would if the manifest was right!) This would be a neat concept for CruiseControl.Net.
This would work in the following way:
- A developer writes a new plug-in/theme/etc.
- When it is completed, they zip all the files into a package and then add a manifest saying what needs to be copied and configured.
- This package is then distributed.
- An administration retrieves the package.
- They start up the dashboard, and import the package – this then displays the package details.
- If the administrator is happy they then install the package, which loads all the files into the correct places and adds the configuration.
- The administrator is then done
This involves a little more work for the developer, but a lot less work for the administrator! Additionally the risk of user error is reducing significantly.
Sound good? If so, read on, because I have put together a working prototype.
Package Importer
First off, what is the package and what does it contain?
I’ve defined a package as a zip file, that contains all the necessary files, plus an XML manifest. I’ve put together an example package for the download CCTray functionality:
This contains the installer for CCTray, plus the manifest file (there are no templates or binaries required because this is part of the standard install). The manifest file is called “manifest.xml” – this is very important because the package importer needs to find the file, so I’ve based the search on the file name.
The contents of the manifest looks like this:
1: <package>
2: <name>CCTray Download</name>
3: <description>Allow a user to download the installer for the CCTray application.</description>
4: <type>Plugin</type>
5: <folders>
6: <folder>
7: <location>CCTray</location>
8: <files>
9: <file>CruiseControl.NET-CCTray-1.4.3-Setup.exe</file>
10: </files>
11: </folder>
12: </folders>
13: <configuration>
14: <setting>
15: <path>/dashboard/plugins/farmPlugins</path>
16: <name>cctrayDownloadPlugin</name>
17: </setting>
18: </configuration>
19: </package>
This defines all the files (in folder elements), plus the configuration changes to make. I’ve tried to keep the format as simple as possible, but hopefully still cover everything.
The actual package importer is a dashboard plug-in. This means an administrator can remove it if they want to (it’ll also be secured under 1.5 so the user must have admin rights).
The farm level menu for the dashboard will look like this:
There are two things to notice:
- First there is the new package menu (I’ve highlighted it to ensure people see it, the green bits aren’t in the HTML)
- There is no CCTray download option – I’ve removed it to show that things do work
Clicking on the menu option displays the following view:
This allows the administrator to select the package to import. Selecting a file and clicking import will copy the package to the server and validate it (it needs a manifest file). However, it doesn’t install it, instead it just tells the administrator about the package:
This allows the administrator to check that the package contains what they actually want! From 1.5, the administrator will be able to install both plug-ins and themes, hence the type label above.
If the administrator is happy, they click on “Yes” and the package is installed. Rather than forcing the administrator to guess about what has happened, a log view is displayed:
The files in gray are extra information – more useful for the developer, rather than administrator – but I’m trying to plan ahead. If there are any warnings or errors, they will also be displayed in this log.
As well as copying the files and changing the configuration, the package loader will also force a reload of the configuration. This gives the following result:
I included the before image in this screenshot, just so it is obvious what has changed. The “Download CCTray” option has been added, and I didn’t even need to restart IIS!
Where To From Here?
At the moment, this is still a very rough prototype. Here are my plans:
I want to do some more work around packages. The process currently has two steps: load the package and then install it. I’m planning on making a packages repository, where the administrator can upload multiple packages. We’ll also pre-install a number of packages to simplify installation of the dashboard.
This repository means the administrator can load packages, and then install or un-install as required. Plus they’ll be able to delete packages from the repository.
Also, as I stated above, I want to make packages reversible. If an administrator decides they don’t want a plug-in or theme in the future, they can go to the repository and un-install the package.
Finally, I want to do some tidying up around the log – it would be nice to hide the developer-only messages by default, but still give the developer the option to view them.
Anyway, these are my thoughts, what do you think of the concept?