Search code examples
jirakanban

Is there a way to automatically change epic state to done when all the linked stories and tasks are complete


I am new to JIRA and Kanban. I was expecting that when I create an epic and link some stories and tasks to it. The status of the epic will automatically change (e.g. to done) when all the stories and tasks linked to it are done. But it seems this is not the case. I can move the epic from the Backlog to the Done column even when its linked tasks and stories are still in the backlog. Is there a way to make JIRA prevent that from happening?


Solution

  • I have been working on something similar. My intention was to set assigne of all linked issues of another one to a specific user when the status changes to a specific state.

    I did this with a postfunction of the workflow of type: "Set Field Value to constant or Groovy expression"

    In your situation I would do the following:

    • go to "Close" transition, and click configure.
    • select postfunctions, and add the type i told you.
    • mark the chekbox that says execute only if condition is true
    • set your condition. Probably something like issue.epic=your epic.
    • Then you add your script, where you recover alll the issues linked to the epic, and check their status.
    • Create your logic so that if everithing is as it should be, you just change the status, using MutableIssue object.
    • remember that a field is going to be modified by this script, and i guess you cant choose status as field to be set. If this happens, choose summary, and store the current value, and use it to end your script, and set the summary value, whtih the same you had.
    • Publish your workflow.

    Excuse me if it is not clear, but is difficult to explain. Let me know if you need somenthing else.

    PD: If you just want to do this at some specific moment and not for every epics automatically, just add Script Runner plugin, and run your script in the console. Much easier.

    Regards