File Content Replacer
A build feature which processes text files by performing regular expressions
Example. Finds all the 'Properties/AssemblyInfo.cs' files on the agent under the build checkout directory and performs replacement there according to the provided regular explression. All the strings matched by the regexp will be replaced with the current build number.
buildType {
// Other Build Type settings ...
features {
// Other Build Features ...
replaceContent {
fileRules = "**/Properties/AssemblyInfo.cs"
pattern = """(^\s*\[\s*assembly\s*:\s*((System\s*\.)?\s*Reflection\s*\.)?\s*""" +
"""AssemblyFileVersion(Attribute)?\s*\(\s*@?\")(([0-9\*])+\.?)+(\"\s*\)\s*\])"""
replacement = "%system.build.number%"
}
Content copied to clipboard }
}
See also
Types
Properties
Whether the search should be case-sensitive. Enabled by default. A value of ``false``
sets CASE_INSENSITIVE and UNICODE_CASE flags. Set to ``false``
for case-insensitive languages (e.g. Visual Basic).
A name of the custom encoding to use, works when encoding is set to FileEncoding.CUSTOM
Enables/disables build failure in case there are no files matching the specified file pattern. Enabled by default.
Pattern to search for, either in the regular expression (default) or in the fixed strings format, depending on the regexMode.
Controls the way the search pattern and the replacement text are interpreted. The default is RegexMode.REGEX. Set to RegexMode.FIXED_STRINGS to perform a fixed strings search.
Replacement text. In REGEX mode, ``$N``
sequence references ``N``
-th capturing group. All backslashes (``\``
) and dollar signs (``$``
) without a special meaning should be quoted (as ``\\``
and ``\$``
, respectively). In REGEX_MIXED and FIXED_STRINGS modes, backslashes (``\``
) and dollar signs (``$``
) have no special meaning.
Functions
Copies parameters of this object to the specified target
Creates an instance of this build feature via reflection using a no argument constructor, used during copying. Throws an error if this class doesn't have a default constructor. Subclasses can override it to create an instance without using a default constructor.
Validates this object and reports found errors to the provided consumer