View Source

h3. Definition

File patterns are widely used in QuickBuild to specify a set of directories or files. For example, the artifact publishing step has a property _File Patterns_ which is used to specify files and directories to be published as artifacts.

File patterns are described using [EBNF|http://en.wikipedia.org/wiki/EBNF] as below:
{code}
file patterns::=file pattern,{",",file pattern}
file pattern::=[+|-]Ant pattern
{code}
Here:
# _Ant pattern_ refers to [Ant based path patterns|http://ant.apache.org/manual/dirtasks.html#patterns]
# File pattern can be constructed by prefixing "+" or "-" before a Ant pattern:
#* if prefixed with "+", the file pattern will be used to include files or directories
#* if prefixed with "-", the file pattern will be used to exclude files or directories
#* if not prefixed, the file pattern is considered to be a include pattern (that is, have the same effect as prefixing a "+" character)
# file patterns are a series of file pattern connecting together through the comma character

h3. Examples

Here we will use the artifact publishing step to give examples of file patterns in QuickBuild. Let's suppose that:
# the configuration workspace locates at _/opt/quickbuild2/configurations/1/workspace_, and it contains below directories and files:
{code}
file0.zip
file0.doc
dir1/
file1.zip
file1.doc
dir2/
file2.zip
file2.doc
dir3/
file3.zip
file3.doc
{code}
# the build artifacts directory locates at _/opt/quickbuild2/builds/1/artifacts_
# The property _From Directory_ of artifact publishing step is left empty, which means that the workspace directory will be used as the base of file pattern matching.
# The property _Destination Directory_ of artifact publishing step is left empty, which means matched files and directories will be copied over to the artifacts directory.

Now we will examine several file patterns to see what the artifacts directory will like after the publishing:
# *\*\*/\**
All files and directories will be published from workspace directory to artifacts directory recursively. The artifacts directory will look just the same as the workspace directory:
{code}
file0.zip
file0.doc
dir1/
file1.zip
file1.doc
dir2/
file2.zip
file2.doc
dir3/
file3.zip
file3.doc
{code}
# *\*\*/\*.zip*
All zip files will be published recursively. The artifacts direcory will look like:
{code}
file0.zip
dir1/
file1.zip
dir2/
file2.zip
dir3/
file3.zip
{code}
# *\*.zip*
All zip files that is directly under the workspace will be published. The artifacts directory will look like:
{code}
file0.zip
{code}
# *\*\*/\*.zip,-dir2/\*\*/\**
Publish all zip files recursively, but exclude all files under the dir2 directory recursively. The artifacts
directory will look like:
{code}
file0.zip
dir1/
file1.zip
{code}
# *\*\*/\*.zip,-dir2/\**
Publish all zip files recursively, but exclude all files that is directly under the dir2 directory. The artifacts
directory will look like:
{code}
file0.zip
dir1/
file1.zip
dir2/
dir3/
file3.zip
{code}