Note that this capability is only available for the following MettleCI releases:

  • MettleCI Workbench build 1658 or later

  • MettleCI Command Line Interface build 243 or later (this includes the required version of the Compliance Plugin)

  • MettleCI Compliance Plugin build 421 or later (this is the plugin on its own which can be downloaded to replace the plugin in an existing installation of the CLI)

Each Compliance rule can be augmented with additional rule metadata through the use of annotations, the most significant of which is the Tag annotation which is described here.

Rule Annotations

Annotations add extra information to a Compliance rule for use by the MettleCI Workbench and CLI to change their behaviour. Annotations consist of a keyword starting with an @ character followed by relevant metadata. The only annotation you need to use on a day-to-day basis is the @Tag annotation which, although optional, is strongly recommended.

If you add a @Tag attribute to a rule you must also add a package value to the top of your Compliance rule. This is required by the underlying Compliance technology, and has no functional implications.

A good practice for the package name is to use a unique value which identifies the group that owns (and is responsible for maintaining) the rule. All out-of-the-box rules have a set of suggested tags and a package name of datamigrators.

Rule Tags

Each Compliance rule may specify zero or more tags which are free-form text labels associated with each rule. You may choose any number of tags, and each tag may take any alphanumeric value you choose. Rule Tagging provides improved rule metadata management in support of a number of use cases:

The example CI/CD build pipelines that ship with MettleCI demonstrate the use of tags to identify which rules inhibit the successful completion of CI.

Using Tags

Here’s an example of a rule definition which incorporates some Tags.

# Rule attributes
package datamigrators

# Rule tags (effectively user-defined, free-form attributes)
@Tag("security")            # This rule identifies a potential security vulnerability
@Tag("portability")         # This rule identifies a issues with assets' portability between environments
@Tag("maintainability")     # This rule identifies a potential maintainability issue
@Tag("CorpDataWarehouse")   # This rule is specific to the 'CorpDataWarehouse' team
@Tag("fail-ci")             # This rule is mandatory and so should fail continuous integration if breached

# Rule definition
<blah blah blah>

Include and Exclude options for Compliance operations

The various MettleCI tools which use the Compliance Rule library permit the filtering of the rules which they use by allowing users to specify which tags should cause a rule to be included and which excluded.

The mettleci compliance test command (available within the Compliance namespace of the MettleCI Command Line Interface) provides -include-tag and -exclude-tag options to filter the rules which will be used by the command. MettleCI interprets these options so that set of include tags is used first to generate a set of candidate rules, then the set of exclude tags is removed to leave the rules that will be used. In the diagram above, only the rules with tags in set A and NOT in B will be used to select Compliance Rules (formally referred to as the 'relative complement of B in A').

Some notes on Tag behaviour:

Workbench Configuration

The MettleCI Workbench permits you to specify which include and exclude tags will be used when testing your Job’s Compliance interactively from within the Workbench interface.