It is relatively simple to marry FitNesse to your source code control system. It's all handled through a FitNesse variable named CM_SYSTEM. As with all variables, if this variable is !defineed on a page, then it will apply to that page and all pages below it. Otherwise if either the CM_SYSTEM environment variable or java system property is set, it will apply to all pages.
Let's say you want to marry FitNesse with git. You could start FitNesse this way:
The value of this variable is the fully qualified name of a class that looks like GitCmSystem (see below). Make sure that class in in your classpath when you start fitnesse.
Here's the plugin I use for git. This ships with FitNesse so you can use it if it works for you.
The three functions: cmUpdate, cmEdit, and cmDelete are called if:
Remember that each page is defined by a directory that bears it's name, and two files that contain it's content.
The first file is content.txt which holds the wiki text. The second is properties.xml which holds all the metatdata
for the page. The file operations cmEdit and cmUpdate are called for each file. The file argument is the relative
path of the file. The cmDelete function is called with the relative path of the directory that holds the content of
the deleted page. These paths are relative to the -d argument of FitNesse
The 'payload' is there just in case you need it. It contains the complete definition of the CM_SYSTEM variable. You can
put whatever you like in this variable, so long as the fully qualified name of your plugin comes first. Use a space to separate the classname from whatever else you want.
What would you put in this payload? You might put your username and password for the CM system... Or you might put the path
of the CM root. Anything you need to make the CM system work...
So given: !define CM_SYSTEM {fitnesse.wiki.cmSystems.MyCmSystem unclebob/password /cm/myResponsitory}
Then the payload would be: fitnesse.wiki.cmSystems.MyCmSystem unclebob/password /cm/myResponsitory
Let's say you want to marry FitNesse with git. You could start FitNesse this way:
java -DCM_SYSTEM=fitnesse.wiki.cmSystems.GitCmSystem -jar fitnesse.jarOr, if you just wanted to put a sub-hierarchy of pages under git, then put
!define CM_SYSTEM {fitnesse.wiki.cmSystems.GitCmSystem}in the top page of that hierarchy. If you want turn the CM marriage off below some point in the hierarhcy, just put a !define CM_SYSTEM {} just above that level.
The value of this variable is the fully qualified name of a class that looks like GitCmSystem (see below). Make sure that class in in your classpath when you start fitnesse.
Here's the plugin I use for git. This ships with FitNesse so you can use it if it works for you.
public class GitCmSystem {
public static void cmUpdate(String file, String payload) throws IOException {
Runtime.getRuntime().exec("/usr/local/bin/git add " + file);
}
public static void cmEdit(String file, String payload) {
//git doesn't need this.
}
public static void cmDelete(String file, String payload) throws IOException {
Runtime.getRuntime().exec("/usr/local/bin/git rm -rf --cached " + file);
}
}
The three functions: cmUpdate, cmEdit, and cmDelete are called if:
- The name of the class is in the CM_SYSTEM variable, and
- that page is being created, modified, or deleted.
- cmEdit(file, payload) is called just before file is about to be written
- cmUpdate(file, payload) is called just after file has been written
- cmDelete(directory, payload) is called just after the directory defining a page has been deleted.
Remember that each page is defined by a directory that bears it's name, and two files that contain it's content.
The first file is content.txt which holds the wiki text. The second is properties.xml which holds all the metatdata
for the page. The file operations cmEdit and cmUpdate are called for each file. The file argument is the relative
path of the file. The cmDelete function is called with the relative path of the directory that holds the content of
the deleted page. These paths are relative to the -d argument of FitNesse
The 'payload' is there just in case you need it. It contains the complete definition of the CM_SYSTEM variable. You can
put whatever you like in this variable, so long as the fully qualified name of your plugin comes first. Use a space to separate the classname from whatever else you want.
What would you put in this payload? You might put your username and password for the CM system... Or you might put the path
of the CM root. Anything you need to make the CM system work...
So given: !define CM_SYSTEM {fitnesse.wiki.cmSystems.MyCmSystem unclebob/password /cm/myResponsitory}
Then the payload would be: fitnesse.wiki.cmSystems.MyCmSystem unclebob/password /cm/myResponsitory
Add Child Page to SourceCodeControl