Automation rule to move issue to DONE only when multiple MR's are merged
Asked by Nirmal Nath:

Came across this limitation in Jira. We are adding multiple MR's to one ticket and when applied the template rule to move the ticket to DONE when the MR is merged it moved the ticket even if only one MR is merged, what should be the rule to check for all the MR's state is MERGED and only move to DONE if this condition is true.


Answers:
author: Dick
body: Hi Nirmal,

Sometimes, one should look to a problem from the other side.

In your case:

* gather the list of MR's (whatever they may be, I have no clue here :) )
* check the list for **non-merged** MR's.
* if this check yields you zero items, then set the status of the ticket to Done.

I hope this will help you.

Dick

comments: author: Nirmal Nath
body: I tried to play around with the template "When a pull request is merged ? then move issue to done". But I could not find a smart value condition which will check for non-merged MR's. This rule will not wait for other MR to be merged but change the ticket to DONE when any one of the MR is merged!  

Forgot to mention, we are tagging the MR using the \`Development\` option in jira.


author: Nirmal Nath
body: Can you guide me on how to gather the list of MR's which are tagged in the Ticket using the automation rules. TIA


author: Dick
body: well, you could start by sharing what you have now...   
maybe I can help out with syntax or by looking at your problem from a different angle.

:)


author: Dick
body: Ah, MR is a Merge Request (sorry I didn't get that in the first place).   

If you're coupling merge requests to a ticket, the ticket key is usually used as the first part of the merge request name. From whatever tool you're using to integrate Git into Jira, you'll need to access the synchronized GIT repository in Jira from within this Jira plug-in to find how many merge requests a ticket has.


author: Nirmal Nath
body: Hi [@Dick](/t5/user/viewprofilepage/user-id/4586768) , We have configured Jira to couple merge requests to the ticket, We are not blocked there. Let me share some SS.

Here we have 2 MR's attached to the ticket. You can notice the status is changed automatically to 'DONE' when one of the MR is merged. We don't want that to happen. We want to change the status automatically only when all the attached MR's is merged.  
![Screenshot 2024-09-12 at 1.04.17?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/346981iB73654F59B27A353/image-dimensions/157x210?v=v2 "Screenshot 2024-09-12 at 1.04.17?PM.png")![Screenshot 2024-09-12 at 1.05.05?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/346982i237ED8328CDA699D/image-dimensions/341x130?v=v2 "Screenshot 2024-09-12 at 1.05.05?PM.png")

We have used the Automation in the Jira project to achieve this. Is it possible to add some condition in the rule to check for all the MR's status and move the ticket to 'DONE' only if everyone of them is in 'MERGED' status.  
![Screenshot 2024-09-12 at 1.07.21?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/346983i6C208675B61493F7/image-size/large?v=v2&px=999 "Screenshot 2024-09-12 at 1.07.21?PM.png")


Tags: action

automation

cloud

jira-cloud