How to find all issues associated with a pull request?
Asked by Ignacia:

I've been using Jira automation rules and GitHub to track the development process on my team, and we've been struggling with this issue.

At the moment, we have a rule that works only when one issue is linked to one pull request (see below), writing the issue key on the title of the pull request. But my objective is to make a rule such that "When a pull request is merged, all the issues that are linked to that pull request transition to the status 'Ready For Build'", since sometimes multiple Jira issues/development issues are addressed on a single branch and then a single pull request is needed.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/166032i2D589782FD861561/image-size/large?v=v2&px=999 "image.png")

From the question ["Update multiple issues, that are not linked, using Jira Automation"](https://community.atlassian.com/t5/Automation-questions/Update-multiple-issues-that-are-not-linked-using-Jira-Automation/qaq-p/1608219) the solution seems to be using a branch action and a JQL query (see the second figure below). But the thing is that I've not been able to find a way to detect all the issues associated with the merged pull request using JQL. Is there a way to do this?

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/166035i061E7C39F72721AA/image-size/large?v=v2&px=999 "image.png")

I've already checked that the pull request linked all my issues. In my case, the branch name was "WF-1009-WF-542-WF-635-model-plot" and the pull request title was something like "WF-1009 WF-542 WF-635: fixes of ..... #49", so the pull request #49 is correctly linked to the issues WF-1009, WF-542 and WF-635. Furthermore, every issue has the branch "WF-1009-WF-542-WF-635-model-plot" associated.


Answers:
author: Bill Sheboy
body: Hi [@Ignacia Sanchez](/t5/user/viewprofilepage/user-id/4603559) -- Welcome to the Atlassian Community!

I note in your screen grab that there is an error icon by the JQL branch. Did you define the JQL for the branch? If not, you could probably move the JQL from the condition immediately below it to the branch, and then delete the condition.

Or, move it above as shown in this article which is quite similar to your use case:

<https://www.atlassian.com/devops/automation-tutorials/jira-automation-rule-on-pullrequest-merge>

Kind regards,  
Bill

comments: author: Ignacia
body: Hello Bill! Yes, the error icon is because (for the purpose of taking the screenshot) I didn't add any JQL query haha. The main question is precisely how to make a query in that block that detects all the Jira issues associated with the merged pull request :)


author: Bill Sheboy
body: Sorry, I am not currently set up to test this rule with a build pipeline...My understanding was that trigger fires for each issue associated to the PR. Is that not the case you are observing (i.e. it is firing only once, and not once per issue)?


author: Ignacia
body: Yes, my understanding was also that the trigger would fire for each issue associated to the PR, but the main thing is that is not happening, and that's why I searched for another way of doing it. In this case, I found that maybe I could do it with a JQL, but I dont know how to access to *"all Jira issues associated with the merged pull request"*

To complement the comprehension of the problem, here's some audit logs for the rule \[F\] that I thought It will work, but It didn't: The Jira Issue WF-636 had only one Pull request associated, so it worked properly. But the Jira Issues WF-1009, WF-542 and WF-635 (that where associated all to one pull request), didn't worked. The rule developmen\[pullrequests\].open = 0 was true for all of them.

PS: I added only the audit log for the Jira Issue WF-635, but for WF-1009 and WF-542 the image is the same. ![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/166231i55C81C904D2A4ED4/image-size/large?v=v2&px=999 "image.png")![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/166230i498D3532F4CA1BD5/image-size/large?v=v2&px=999 "image.png")


author: Bill Sheboy
body: Thanks for that info! Based on your findings, you could branch with some adjustments to your rule. Please try this to see how it helps:

* trigger: pull request merged
* branch: on JQL, changing *myProject* to your project

```
project = myProject 
 AND issueType NOT IN (Story, Epic) 
 AND?development[pullrequests].open = 0
```

*
  * action: transition the issue


author: Ignacia
body: I don't think this will work since my objective is only to transition the issues that are related to the pull request that's been merged. In fact, I wrote this JQL query on the advanced Issue navigator and more than 700 Jira issues where returned.

What I really need is, on a branch, some JQL query like:

```
project = myProject 
AND issueType NOT IN (Story, Epic) 
AND?development[pullrequests].open = 0?
AND pullrequest.Number = development[pullrequestNumber] 
```

And my main question is precisely if something like **pullrequest.*Number = development\[pullrequestNumber\]*** exists in Jira, or if there is some other way to access all the related issues of the merged pull request, so that every related issue with the pull request will be transitioned.


author: Bill Sheboy
body: I haven't been able to learn that info after a few searches. If you are on a paid license of Jira, please consider working with your site admin to submit this as a support ticket: <https://support.atlassian.com/contact/#/>

And once you hear from them, please consider posting what you learn to benefit the community. Thanks!


author: Ignacia
body: I'll do that, and I'll post it If I know something. Thanks for the help!


author: robrecht-vanmelckebeke
body: Hi, I guess you didn't find a solution?


author: Nishant Shah
body: [@Ignacia Sanchez](/t5/user/viewprofilepage/user-id/4603559) I am also looking for something like this. Did you manage to find a solution?


Tags: filter

github

jql

pull-request