Dashboard > CruiseControl.NET > ... > Source Control Blocks > Filtered Source Control Block
Filtered Source Control Block Log In View a printable version of the current page.  
CruiseControl.NET documentation for latest CI builds
Added by Owen Rogers , last edited by Ross Patterson on Apr 28, 2008  (view change) show comment

What is FilteredSourceControl?

The FilteredSourceControl allows you to filter out modifications that are used to trigger a build. If for example, you have certain files (such as web pages or document files) under source control that you don't want to have trigger the build, you can use this class to ensure that their changes will keep a new build from launching.

The FilteredSourceControl works together with all of the source controls supported by CCNet (including the Multi Source Control Block). It can also be included under the Multi Source Control Block provider so that you could have multiple FilterSourceControls each filtering a different set of modifications from different source control providers. Essentially, it acts as a decorator (or an example of the pipes and filters pattern ), wrapping around the specific SourceControl provider that you want to use.

The FilteredSourceControl includes both inclusion and exclusion filters for specifying what modifications should be included/excluded. Multiple inclusion and exclusion filters can be specified or, alternately, no inclusion or exclusion filter could be specified. If a modification is matched by both the inclusion and exclusion filter, then the exclusion filter will take preference and the modification will not be included in the modification set. At this point, CCNet only supports three types of filters: PathFilters, UserFilters, and ActionFilters. It is relatively straightforward to build new filters, (such as one to filter modifications based on email address).

Configuration Examples

<sourcecontrol type="filtered">
    <sourceControlProvider type="vss" autoGetSource="true">
      <project>$/Kunigunda/ServiceLocator</project>
      <workingDirectory>C:\CCNet\Kunigunda\ServiceLocator</workingDirectory>
      <username>urosn</username>
      <password></password>
      <ssdir>c:\localvss</ssdir>
    </sourceControlProvider>
    <inclusionFilters>
      <pathFilter>
      	<pattern>$/Kunigunda/ServiceLocator/Sources/**/*.*</pattern>
      </pathFilter>
    </inclusionFilters>
    <exclusionFilters>
    	<pathFilter>
    		<pattern>$/Kunigunda/ServiceLocator/Sources/Kunigunda.ServiceLocator/AssemblyInfo.cs</pattern>
    	</pathFilter>
	<pathFilter>
		<pattern>$/**/*.vssscc</pattern>
	</pathFilter>
	<userFilter>
		<names><name>Perry</name><name>Joe</name></names>
	</userFilter>
	<actionFilter>
		<actions><action>deleted</action></actions>
	</actionFilter>
        <commentFilter>
                <pattern>Ignore: .*</pattern>
        <commentFilter>
    </exclusionFilters>
</sourcecontrol>

This example filters out any modifications to the AssemblyInfo.cs file that have been checked in to Visual Source Safe Source Control Block. Although it shows the use of all four types of filters, you can choose to use only fewer types of filter as well.

Configuration Elements:

FilteredSourceControl root element

This is the root configuration element for the FilteredSourceControl.

Node Description Type Required
sourceControlProvider This element is used to specify the type of source control provider to retrieve modifications from. With the exception of the element name, the configuration for this element is identical to the xml configuration for the specific source control provider you intend to use. xml element true
inclusionFilters Specifies the filters that should be used to determine which modifications should be included. This element should contain the xml configuration for one or more filters. xml element false
exclusionFilters Specifies the filters that should be used to determine which modifications should be excluded. This element should contain the xml configuration for one or more filters. xml element false
Unlike most source control blocks, this one does not support the timeout configuration element

PathFilter element

The PathFilter can be used to filter modifications on the basis of their file path.

Node Description Type Required
pattern This is the pattern used to compare the modification path against. The pattern should match the path of the files in the repository (not the path of the files in the working directory). See below for examples of the syntax for this element. Each PathFilter contains a single pattern element. string true

UserFilter element

The UserFilter can be used to filter modifications on the basis of the username that committed the changes.

Node Description Type Required
names This element consists of multiple <name> elements for each username to be filtered. string true

ActionFilter element

The ActionFilter can be used to filter modifications on the basis of the type of modification that was committed. Modification types are specific to each source control provider. Consult each source control provider for the list of actions to filter.

Node Description Type Required
actions This element consists of multiple <action> elements for each action to be filtered. string true

CommentFilter element

The CommentFilter can be used to filter modifications on the basis of the comment that was supplied with the modification.

Node Description Type Required
pattern This is the pattern used to compare the modification comment against. The pattern is specified according to the rules of the .net System.Text.RegularExpressions.Regex class. Each CommentFilter contains a single pattern element. string true
Comment filters are available starting with build #1.3.0.3052.

Using the PathFilter:

PathFilter supports following wildcards:

Wildcard Used as Matches Example
*" part of the path none or exactly one subfolder Pattern "/Kunigunda/*/Sources/*.*" matches "/Kunigunda/Sources/*.*", "/Kunigunda/Service/Sources/*.*", and "/Kunigunda/Web/Sources/*.*"
"*" part of the folder name zero or more characters that can appear in the folder name Pattern "/Kunigunda/Sources/Test*/*.*" matches "/Kunigunda/Sources/Test/*.*" and "/Kunigunda/Sources/Tests/*.*"
"*" part of the filename zero or more characters that can appear in the file name Pattern
"/Kunigunda/Sources/*.cs" matches all filenames in the "/Kunigunda/Sources" folder ending in ".cs". Pattern "/Kunigunda/Sources/*Test.cs", matches all filenames in the "/Kunigunda/Sources/" folder that end with "Test.cs".
"*" part of the extension zero or more characters that can appear in the extension. Pattern "/Kunigunda/Sources/Build.*" matches all files in "/Kunigunda/Sources" folder starting with "Build.".
"*" filename any file name and extension Pattern "/Kunigunda/Sources/*" matches all files in "/Kunigunda/Sources" folder.
"*.*" filename any file name and extension Pattern "/Kunigunda/Sources/*.*" matches all files in "/Kunigunda/Sources" folder. Note: "*.*" is exactly the same as "*" as a filename.
"**" part of the path zero or more subfolders. Pattern "/Kunigunda/Sources/**/Test/*.*" matches all files stored in any "Test" subfolder anywhere below the "/Kunigunda/Sources" tree (e.g., "/Kunigunda/Sources/Test/*.*", "/Kunigunda/Sources/Core/Test/*.*").
? anywhere any single character Pattern "/Kunigunda/Sources/Test?.cs" matches all files in "/Kunigunda/Sources" are named "Test" followed by one more character and that end in ".cs".
Paths do not include the roots
Paths do not include the root server identifiers. For example, if you are using subversion source control on server "myserver" and trying to exclude path "svn://myserver/project1/excludedir/*.*" your node should be "/project1/excludedir/*.*".
Path separators are not characters
Path separators are not compared as characters, but rather as separations between path elements. The separators "\", "/" and the .Net System.IO.Path.DirectorySeparatorChar are all treated interchangably. This means that the patterns "/Kunigunda/Sources/Test.cs" and "\Kunigunda\Sources\Test.cs" both match the file named "Test.cs" in the folder named "Sources" under the folder named "Kunigunda".
StarTeam needs the full path
With StarTeam, use the entire file path as recognized by StarTeam, such
as what is displayed when clicking File/Properties/Working File within
StarTeam.

Examples:

c:\project\module1\**
c:\project\module2\**\filethatdoesntaffectbuild.txt

Potential enhancements:

  1. Case insensitive pattern matching.
  2. Current patterns are only an approximation of the patterns used in NAnt filesets. Pattern translation and evaluation types in NAnt assembly are not public so it is not possible to use them directly but it would be a nice optimization.

Implemented and contributed by Uros Novak.
UserFilter and ActionFilter by Perry Ismangil.

Powered by a free Atlassian Confluence Open Source Project / Non-profit License granted to ThoughtWorks, Inc.. Evaluate Confluence today.
Powered by Atlassian Confluence 2.7.1, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators