This section has use cases which help you in understand the usage of Validators provided by JMWE.
...
Block the creation of a Bug if no Attachment is provided.
Expand title Steps Panel - Add the
Scripted (Groovy) validator
to the Create transition. Write the following in the
Groovy script
Code Block language groovy linenumbers true try { return issue.get("issuetype").name != "Bug" && issue.getModifiedFields()?.get("attachment")?.getNewValue()?.size() > 0 } catch (Exception e) { return false }
- Add the
Validate the Cascade select for values in parent and child select dropdowns
Expand title Steps Panel - Add the
Scripted (Groovy) validator
to the transition. Write the following in the
Groovy script
Code Block language groovy linenumbers true issue.get("Cascade")?.get(null) != null && issue.get("Cascade")?.get("1") != null
- Add the
Block the approving of the Change request if it has no confluence page linked
Expand title Steps - Add the
Scripted (Groovy) validator
to the Approve transition. Write this content in the
Groovy script.
Code Block issue.getRemoteLinks("confluence").size() > 0
- Type the error message in
Error message,
to display if the validation script returnsfalse
- Add the
Block the approval of an issue if there is no PDF attached either from before or added during the transition
Expand title Steps - Add the
Scripted (Groovy) validator
to the Approve transition. Write this content in the
Groovy script.
Code Block import com.atlassian.jira.issue.IssueFieldConstants import com.atlassian.jira.issue.attachment.Attachment import com.atlassian.jira.issue.attachment.TemporaryWebAttachment import com.atlassian.jira.issue.attachment.TemporaryWebAttachmentManager if (issue.get("attachment").any{it.filename.endsWith(".pdf")}) return true; TemporaryWebAttachmentManager attachmentManager = getComponent(TemporaryWebAttachmentManager) try { List<Long> ids = issue.getModifiedFields().get(IssueFieldConstants.ATTACHMENT).getNewValue(); if (ids) return ids.any { id -> def attachment = attachmentManager.getTemporaryWebAttachment(id).getOrNull() return attachment?.filename?.endsWith(".pdf") } } catch (Exception e) { } return false
- Type the error message in
Error message,
to display if the validation script returnsfalse
- Add the
...
Related Issues Status validator
This validator can be used to ensure validator ensures that the current issue's linked issues are in related issues (such as linked issues, Stories of an Epic, Epic of a Story, subtasks of an issue, issues returned by a Groovy script or a JQL search, etc.) are in one of the selected specified statuses.
Sample use cases:
Block the transition of the Epic to Closed status, if its stories aren't closed.
Expand title Steps Panel - Add the
Linked Related issues status validator
to the Close transition. - Select the issue link type
is Epic of
the current issue
from theIssue Link Type
Which Issue(s)
field. Select the statuses the linked issues must be in, from
Statuses
Add the error message, "
The Stories of the Epic are not yet resolved
"
- Add the
...
Related Issue(s) validator
This validator can be used to ensure validator ensures that a link link to one (or more) issue(s) from the current issue is being created during the transition. , and/or that existing and/or newly related issues (such as linked issues, Stories of an Epic, Epic of a Story, subtasks of an issue, issues returned by a Groovy script or a JQL search, etc.) have certain characteristics.
Sample use cases:
Block the creation of a Bug, if it is not linked to the corresponding functionality requirement.
Expand title Steps Panel - Add the
Linked Related issue validator
to the Create transition. - Select the
Issues linked to the current issue through the following link type
from theIssue Link Type
field. Select the issue link type
relates to
from theIssue Link Type
field.Add the error message, "
Associate/Link the Bug to the respective requirement ticket
"
- Add the
...