Each Rule can be parametrized when added to Ruleset. In this way Rules can be reused in many contexts.
Rule parameters are placed in Rule script class as fields and have an annotation @RuleParameter. The definition of a parameter is written in the annotation's attributes.
List of parameter types supported in Commithub Rule:
Parameter Type | Description | Sample Definition |
---|---|---|
STRING | Simple String parameter | @RuleParameter(type=RuleParameter.Type.STRING, name="astring") String astring |
INT | Integer parameter | @RuleParameter(type=RuleParameter.Type.INT, name="anInt") int anInt |
DOUBLE | Double parameter | @RuleParameter(type=RuleParameter.Type.DOUBLE, name="aDouble") double aDouble |
BOOL | Boolean parameter | @RuleParameter(type=RuleParameter.Type.BOOL, name="aBoolean") boolean aBoolean |
DATE | Date parameter in YYYY-MM-DD format | @RuleParameter(type=RuleParameter.Type.DATE, name="aDate") String aDate |
GROUPS | Groups parameter which appears as multiple JIRA groups picker, holds names of groups | @RuleParameter(type=RuleParameter.Type.GROUPS, name="groups") String[] groups |
ROLES | Roles parameter which appears as multiple JIRA Project Roles picker, holds IDs of roles | @RuleParameter(type=RuleParameter.Type.ROLES, name="roles") long[] roles |
STATUSES | Statuses parameter which appears as multiple JIRA Statuses picker, holds IDs of statuses | @RuleParameter(type=RuleParameter.Type.STATUSES, name="statuses") long[] statuses |
RESOLUTIONS | Resolutions parameters which appears as multiple JIRA Resolutions picker, holds IDs of resolutions | @RuleParameter(type=RuleParameter.Type.RESOLUTIONS, name="resolutions") long[] resolutions |
VERSIONS | Versions parameters which appears as multiple JIRA Versions picker, holds IDs of versions | @RuleParameter(type=RuleParameter.Type.VERSIONS, name="versions") long[] versions |
COMPONENTS | Components parameters which appears as multiple JIRA Components picker, holds IDs of components | @RuleParameter(type=RuleParameter.Type.COMPONENTS, name="components") long[] components |
PROJECTS | Projects parameter which appears as mutliple JIRA Projects picker, holds IDs of projects | @RuleParameter(type=RuleParameter.Type.PROJECTS, name="projects") long[] projects |
FILTERS | Filter parameter which appears as multiple JIRA Filters picker, holds IDs of filters | @RuleParameter(type=RuleParameter.Type.FILTERS, name="filters") long[] filters |
JQL | JQL parameter which appears as syntax highlighted JIRA JQL field | @RuleParameter(type=RuleParameter.Type.JQL, name="jql") String jql |
REGEXP | Regexp parameter which appears as regular expression text field | @RuleParameter(type=RuleParameter.Type.REGEXP, name="regexp") String regexp |
FIELD | Field parameter which appears as JIRA Custom Field picker, holds a name of the picked field | @RuleParameter(type=RuleParameter.Type.FIELD, name="field") String field |
PREDEF_VALUES_MULTI | Predefined multi-choice parameter, holds IDs of picked options. Values are declared in the values attribute as an array of options. Each option is annotated with @RuleParameterValue and holds attributes id and value as a displayed label. | @RuleParameter(type=RuleParameter.Type.PREDEF_VALUES_MULTI, name="branch", values=[ @RuleParameterValue(id=0, value="branch no. 1"), @RuleParameterValue(id=1, value="branch no. 2"), @RuleParameterValue(id=2, value="branch no. 3") ]) int[] branch |
PREDEF_VALUES_SINGLE | Predefined single-choice parameter, holds an ID of picked option. Values are declared in the values attribute as an array of options. Each option is annotated with @RuleParameterValue and holds attributes id and value as a displayed label. | @RuleParameter(type=RuleParameter.Type.PREDEF_VALUES_SINGLE, name="aBooleanLabeled", values=[ @RuleParameterValue(id=0, value="at least one"), @RuleParameterValue(id=1, value="all") ]) int aBooleanLabeled |
SQL | SQL query which appears in text area | @RuleParameter(type=RuleParameter.Type.SQL, name="sql") String sql |