Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In order to create custom rule You should clone Custom Rule Repository and create use a custom Rule in a Ruleset a new Rule groovy class file . The Repository can be configured using following guide: Custom Rules Repositorymust be created. 

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

Code Block
SampleRule.groovy

Coresponding to that filename the The file inside should look like:

Code Block
languagegroovy
titleSampleRule
linenumberstrue
import re.hub.rest.commit.CommitCheckRequest
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 you should commit and push changes to repository which is configured as Custom Rules Repository. After this commit CommitHub Commit Hub will index the new rule and it will appear in Rule list in RuleSet Ruleset configuration.