Related Issues Validator

 

Documentation for JMWE JMWE 5.0.0 - 6.1.3 is available here.

  • This post-function does not work with remote links (links to Jira issues residing on another Jira instance/server).

  • JMWE now considers "symmetrical" link types (such as "relates to") as one link direction instead of two on the configuration screens and in the validator execution. 

To add 'Related Issues Validator' to a transition:

  1. Click Edit for the workflow that has the transition you wish to configure the validator on.

  2. In the Workflow Designer, select the transition.

  3. Click on Validators in the properties panel.

  4. Click on Add validator.

  5. Select Related Issues Validator from the list of validators.

  6. Click on Add to add the validator on the transition.

  7. Select the related issues from Which issue(s) / Issue link drop-down (depends on the option selected under What to validate)

  8. Select the minimum number of related issues required from the Min. Related Issues field. 

  9. Input a message in the Error message field to display if the configured conditions are not satisfied.

  10. Click on Add to add the validator to the transition.



When you add this validator to a transition and trigger the transition, the add-on checks the number of related issues of specified link type added on the transition screen against the number of issues entered in the Min. Related Issues field. If it does not match then an error message is displayed. 

You can further customize the validation using the following options:

What to validate

Require the creation of issue links on the transition screen: The transition cannot proceed further if at least one issue of the specified link type and respecting the constraints (explained below) is not linked to the current issue on the transition screen. 

For example: To validate during a transition that at least one issue with “causes” link type is linked

  1. Add the validator to the transition

  2. Select the mode as “Require the creation of issue links on the transition screen”

  3. Select the “Issue link” as “causes”

  4. Input an error message

Validate that issue links added on the transition screen are of the specified link type: The transition cannot proceed further if the issue links added on the transition screen if any, are not of the specified link type, and do not respect the constraints (explained below).

For example, Validate during a transition that issue links of “is blocked by” link type are “Bugs”

  1. Add the validator to the transition

  2. Select the mode as “Validate that issue links added on the transition screen are of the specified link type”

  3. Select the “Issue link” as “is blocked by”

  4. Input the following groovy script in “Condition on related issues:

    1 relatedIssue.issuetype.name == "Bug"

     

  5. Input an error message

Validate issue links added on the transition screen, if they are of the specified link type: The transition cannot proceed further if issue links of the specified link type when added on the transition screen, do not respect the constraints below.

For example: Validate during a transition that issue links of “is blocked by” link type when added are assigned

  1. Add the validator to the transition

  2. Select the mode as “Validate issue links added on the transition screen, if they are of the specified link type”

  3. Select the “Issue link” as “is blocked by”

  4. Input the following groovy script in “Condition on related issues:

    1 !!relatedIssue.assignee

     

  5. Input an error message

Require certain related issues: The transition cannot proceed further if related issues respecting the constraints below do not exist. If the relationship is based on issue links ("blocks", "is cloned by" etc), these issue links can either already exist or be added on the transition screen.

For example, Validate during issue creation that a Story is linked to an Epic

  1. Select the mode as “Require certain related issues”

  2. Select the “Which issues” as “Epic of the current issue”

  3. Input an error message

Check related issues: The transition cannot proceed further if existing related issues of specified link type do not respect the constraints below. If the relationship is based on issue links ("blocks", "is cloned by" etc), these issue links can either already exist or be added on the transition screen.

For example, Validate during a transition that the issue has subtasks

  1. Select the mode as “Require certain related issues”

  2. Select the “Which issues” as “Sub-tasks of the current issue”

  3. Input an error message

Forbid certain related issues: The transition cannot proceed further if related issues respecting the constraints below exists. 

For example. Validate during closing an issue there are no blocked issues.

  1. Select the mode as “Forbid certain related issues”

  2. Select the “Issue link” as “is blocked by”

  3. Input an error message

Select the link from the Issue Link drop-down, or leave it as Any for any link type. Applicable to options "Require the creation of issue links on the transition screen" and "Validate issue links added on the transition screen, if any" of Related Issues Validator#What to validate section

Which issue(s)

Applicable to options "Require certain related issues" and "Check related issues" of Related Issues Validator#What to validate section. Select the issues to check the constraints on. They can be:

  • Linked issues: Select issue(s) linked to the current issue through any link type or a specific link type such as blocks, is cloned by, etc.

  • Sub-tasks of the current issue: Select this option to operate on the sub-tasks of the current issue

  • Parent issue of the current sub-task: Select this option to operate on the parent of the current issue

  • Issues that belong to the current Epic: Select this option to operate on the issues that belong to the current Epic

  • Epic of the current issue: Select this option to operate on the Epic of the current issue

  • Child issues of the current issue in the Portfolio hierarchy: Select this option to operate on the child issues of the current issue in the Portfolio hierarchy

  • Parent issue of the current issue in the Portfolio hierarchy: Select this option to operate on the parent issue of the current issue in the Portfolio hierarchy

  • Issues returned by a Groovy script:  Input a Groovy script that returns either a single Issue object, or a Collection of Issue objects, or a String representing the key of an issue, or a Collection of Strings each representing an issue key. For example:

    • "TEST-1"

    • ["TEST-1","TEST-2"]

    • ComponentAccessor.issueManager.getIssueObject("TEST-1")

    • [ComponentAccessor.issueManager.getIssueObject("TEST-1"),ComponentAccessor.issueManager.getIssueObject("TEST-2")]

    • issue.parentObject

    • issue.getLinkedIssues()

  • Issues returned by a JQL search:  Input a JQL search expression, including an optional Groovy Template markup. For example:

    • project = TEST returns issues of the project with the key TEST

    • project = ${issue.get("project").key} and assignee = ${currentUser.name} returns issues of the project the current issue belongs to and assigned to the current user.

    • To operate on issues of a project with key TEST and issue type name same as the value in a text field

      1 2 3 4 5 <% if (issue.get("Single line text")) { %> project = TEST and issuetype = ${issue.get("Single line text")} <% } else { %> issuekey=INVALID-1 <% } %>

       

  • Note that the <% if %> block is necessary to avoid an invalid JQL query when the Single-line text field is empty. In that case, the template will return a valid JQL query that returns no issue (issuekey=INVALID-1). This is in general applicable to JQL operating on select type fields with pre-determined values like Affects Version/s, Checkboxes etc.

  • The maximum number of issues returned by a valid JQL is limited to 1000.

Issue constraints

Select the minimum number of related issues to be accepted. By default, it is 1.

Select the maximum number of related issues to be accepted. Leave it blank for no limit.

Input a Groovy condition in this field to check on each related issue. Leave blank if you don't need any constraint on the related issues. See the Groovy editor help for more information on writing the Groovy condition.

By default, this option is checked and the Groovy condition written above is checked on each related issue of the current issue. If you uncheck this option, at least one related issue, instead of all, must verify the condition.

Validator Scope

Control the execution of the validator using this option. Check this option if you want the validation to be performed only in certain cases, such as if the issue is of certain issue type or only if the issue is unassigned, or more generally satisfies an arbitrary Groovy expression.