Hello,
I hope you are doing well!
I would like to create an workflow validator that:
If the childes are not done, then you cannot make this transition!
And I want for all the issue types that can be a child in the epic: story, task... without bug. If is a bug and is not done you can close the epic is not a problem.
Thanks!
Regards,
David
Hi David,
I can confirm that to achieve your requirement, you can use the Workflow Validators feature that ScriptRunner for Jira Cloud provides to make the assignee field required on the transition screen.
Workflow validators use the Jira Expression framework provided by Atlassian, and I can confirm we have some examples here to show their syntax.
I can confirm we have an example validator here on line 72 that will help to achieve your requirements.
I hope this information helps.
Regards,
Kristian
Hello,
Thank you for this documentation it helped.
Here is a final version that I used, when i have more "Done" statuses.
Maybe will help someone:
issue.isEpic && issue.stories.every(story => (
(story.issueType.name == 'Bug' && story.status.name != 'Done')
||
(story.issueType.name == 'Bug' && story.status.name == 'Done')
||
(story.issueType.name != 'Bug' && (story.status.name == 'Done' || story.status.name == 'Resolved' || story.status.name == 'Closed' || story.status.name == 'Mitigated' || story.status.name == 'Duplicate' || story.status.name == 'Defer' || story.status.name == 'Rejected'))
))
Regards,
David.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David,
I am glad we helped you to solve your requirement.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kristian your script above to prevent parent if child issues are not Done works fine for issues under a Epic parent. however we have a custom issuetupe UAT which sit on the same level as a Epic but the script "issue.isEpic" only works for issues in Epic. is there any alternative for example issue.isParent for any parent (NOT a Epic) issues?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @David Plesu
It's Mary from Planyway for Jira
To create a Jira workflow validator that restricts the transition of an epic if its child issues (stories, tasks, etc.) are not done, excluding bugs, you'll need to use Jira's workflow editing capabilities. If your Jira instance has ScriptRunner installed, you can achieve this with a Groovy script. If you don't have ScriptRunner or a similar plugin, you might need to look for a plugin that offers custom workflow validation or consider writing a plugin yourself if you have development resources.
Here's a high-level approach using ScriptRunner to create a custom validator:
Ensure you have ScriptRunner for Jira installed since we'll be using it to write a custom script for the validator.
You'll need to write a Groovy script that checks if all child issues (excluding bugs) are in a "Done" status. Here's an example script that you might use or adapt:
import com.atlassian.jira.component.ComponentAccessor
def issueLinkManager = ComponentAccessor.issueLinkManager
def subTaskManager = ComponentAccessor.subTaskManager
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def epicLinkField = customFieldManager.getCustomFieldObjects(issue).find { it.name == "Epic Link" }
def epicLink = issue.getCustomFieldValue(epicLinkField)
// Get all linked issues and sub-tasks
def linkedIssues = issueLinkManager.getLinkCollection(issue, currentUser).allIssues
def subTasks = issue.subTaskObjects
// Filter out bugs and check statuses
def nonDoneIssues = linkedIssues.findAll {
it.issueType.name != "Bug" && it.statusObject.name != "Done"
} + subTasks.findAll {
it.issueType.name != "Bug" && it.statusObject.name != "Done"
}
return nonDoneIssues.isEmpty()
Set an appropriate error message that will be displayed to the user if the validation fails, such as "All child issues must be in 'Done' status to transition this epic, except for bugs."
After adding and configuring the validator, make sure to publish the workflow so your changes take effect.
This script checks all linked issues and sub-tasks of the current issue (assuming it's an epic) to see if they are in the "Done" status, excluding bugs. Adjust the script as necessary to fit your exact field names and statuses.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Maria
Your solution is for Jira Server / DC and will not work in Jira Cloud as validators use the Jira Expression Framework and not Groovy in Jira Cloud.
I hope this helps.
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If you are looking for a wizzard-like solution, we've developed the Linked Issues Validator available as part of the Workflow Building Blocks for Jira app. With a wizard-like UI, you can select options that represent your case. You can choose relations from: sub-tasks, parent issues, epic children, and linked issues. Additionally, you can filter relations by issue types and select criteria based on status category and status.
In your case it would be similar to the following:
If you want to test all children issue types except "Bug", then under "Issue types", select all issue types except "Bug."
I am from Forgappify, the vendor of the app.
I hope it will help.
Cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.