Page tree

In order to use a custom Rule in a Ruleset a new Rule groovy class file must be created. 

Name of the file should correspond to the class name inside this groovy file eg.:


The file inside should look like:

import re.hub.ruleScriptAnnotations.RuleParameter
import re.hub.ruleScriptAnnotations.RuleScript
import re.hub.ruleScriptAnnotations.RuleParameterValue

@RuleScript(ruleName = "SampleRule", ruleDescription = "This is a sample rule with no parameters")
class SampleRule implements CommonRuleScript {

    boolean check(CommitCheckRequest commitCheckRequest, OutputStream outputCommitMessage) {
        return true

The structure of Rule class is described in the next section: Custom Rule structure.

After coding and changing class body you should commit and push changes to repository which is configured as Custom Rules Repository. After this commit Commit Hub will index the new rule and it will appear in Rule list in Ruleset configuration.

  • No labels