How to create Jira Automation Rule using a Wedhook "Pull Request Review" from Github
Asked by Olga Buslovich:

Ive created a rule using the Github Webhook with the "Pull Request Reviews" and "Pull Request" events selected to automate the process for moving the JIRA issues to "QA" when a pull request is "approved" in Github

However, it doesn't work as expected. For some reason the payload that got sent and shown in the Rule Audit log in JIRA doesn't include the "action" or "state" like "approved".

Here is the rule conditions

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

Has anyone tried something similar? Any ideas / suggestions are helpful and very much appreciated !!


Answers:
author: Olga Buslovich
body: I got an update from the JIRA Support on this issue and would like to share here so it might save some of your in case you run into the similar or related issue when using Webhook with A4J.

It turned out that this is a known bug in automation for Jira (A4J) that ignores the incoming webhook headers and the state of the PR is provided inside the webhook header and this information is completely removed from the incoming webhook when being processed by A4J.

As an FYI, here is the ticket that was created to address this problem: [https://jira.atlassian.com/browse/JRACLOUD-76534](https://jira.atlassian.com/browse/JRACLOUD-76534?)

BTW, [@Simmo](/t5/user/viewprofilepage/user-id/3608665) has reported that issue back in 2019 <https://codebarrel.atlassian.net/browse/AUT-1826> it's still in Backlog till now :(

Hope it gets prioritized and fixed sooner this time.

Thanks to ALL who help with the feedback and for sharing your expertise!!

Best,

Olga

comments: author: Ajayi George
body: Hi, is there now a workaround for this? I need help to automate the creation of dependabot tickets from GitHub to Jira using webhooks but the payload that got sent and shown in the Rule Audit log in JIRA doesn't include some fields like 'security_advisory' in my case, please check this out for more details, I asked a question about this.

<https://community.atlassian.com/t5/Jira-Software-questions/Hello-I-need-help-to-automate-the-creation-of-dependabot-tickets/qaq-p/2597879>


author: Olga Buslovich
body: Thanks for your reply [@Simmo](/t5/user/viewprofilepage/user-id/3608665) !!

Now that I know that there are no access permissions involve then I've moved on and tried the [@Darryl Lee](/t5/user/viewprofilepage/user-id/3680306) suggestion.

So I have created a rule and im getting data like the Pull Request number , State (e.g. OPEN) in the Webhook payload json . However, the Pull Request Reviews events that i'm looking for e.g. PENDING. or APPROVED or are not there

Here is what I'm expecting based on the Github documentations:

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

comments: author: Simmo
body: Hi [@Olga Buslovich](/t5/user/viewprofilepage/user-id/3261589) , could you provide an example of what you're getting? That's the easiest way to figure it out.


author: Olga Buslovich
body: Hi [@Simmo](/t5/user/viewprofilepage/user-id/3608665) ,

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


author: Olga Buslovich
body: [@Simmo](/t5/user/viewprofilepage/user-id/3608665) Thanks for looking :)lga


author: Simmo
body: Hi [@Olga Buslovich](/t5/user/viewprofilepage/user-id/3261589)

I'm afraid its been cut off, so its hard to tell but one thing to check is if the information that you're after has been included. With github, some information is optional and needs to be ticked to be included in the webhook.

Cheers,

Simeon.


author: Olga Buslovich
body: Thank YOU [@Simmo](/t5/user/viewprofilepage/user-id/3608665) !!

Actually the Log I've shared has all the data that i got (no cut off ). I'll open a ticket with Github. Thanks again!!

Best,

Olga


author: Darryl Lee
body: Hey there:  

Would you be able to paste in the URL (feel free to obscure the hostname) of your webhook request?

I'm thinking that you might not need **pull_request_review** as that's part of the URL, not what gets returned by the request.

(Reference: <https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#pull_request_review>)

So then, I would try adding a "Log action" of:

```
State: {{webhookData.review.state}} / Action:?{{webhookData.review.action}}
```

To see if that's returning what you're looking for.

(Learn more about "log action" in the [Debugging your first rule](https://confluence.atlassian.com/automation/debugging-your-first-rule-993924612.html) documentation.)

comments: author: Darryl Lee
body: OH. Reading the article [How to integrate Jira and GitHub using Automation for Jira](https://blog.codebarrel.io/how-to-integrate-jira-and-github-using-automation-for-jira-238d19a3be68), [@Simmo](/t5/user/viewprofilepage/user-id/3608665) actually includes **pull_request** in Smart Values used for creating an issue from a webhook.

I guess the best way to check for sure whether you need to include **pull_request_review** is to follow the same steps, which is to add a "Log action" of:

```
{{webhookData}}
```

Which will allow you to see the full JSON payload, and then figure out what Smart Value you should use to get "state" and "action".


author: Darryl Lee
body: If you can do this and paste take a screenshot or paste what the JSON payload is (obfuscating any confidential data), we could help figure out what the Smart Values should be.


author: Olga Buslovich
body: Thanks for your response [@Darryl Lee](/t5/user/viewprofilepage/user-id/1365322) !!

Actually, I was using the [@Simmo](/t5/user/viewprofilepage/user-id/3608665) article as a base for creating conditions in my rule and found very helpful - Thanks [@Simmo](/t5/user/viewprofilepage/user-id/3608665) !!

Before going any further, I'd like to double check if there are any additional permission / access level requirements on the Github side needed to be able to receive and see all the webhook actions / events for the JIRA user who is the owner of the rule?

For Exp, I have Admin privileges for JIRA but I do not Admin for the Github repo and I've asked the Dev Team Lead to create the Webhook for me b/c i do not have the admin permissions for that repository. Is this could be a problem for me not getting all the events / actions in the JSON payload?

Please advise.

TIA!!

Olga


author: Simmo
body: Hi [@Olga Buslovich](/t5/user/viewprofilepage/user-id/3261589),

You shouldn't have any issues with that. Webhooks are not authenticated so you'll be able to receive it okay.

To try and figure out your smart values, take the advice from [@Darryl Lee](/t5/user/viewprofilepage/user-id/1365322) and log out the webhook data. That will show you everything you can access.

Cheers,

Simeon.


author: Darryl Lee
body: Hi - I was doing some work with a client who had connected their Github instance to Jira using the built-in integration, which I believe eliminates the need to get pull request information via a Webhook.

<https://support.atlassian.com/jira-cloud-administration/docs/integrate-with-github/>

Is there a reason why you can't use that integration?

comments: author: Olga Buslovich
body: Hi [@Darryl Lee](/t5/user/viewprofilepage/user-id/1365322) ,

Thank you for following up!!

I've took a look and I believe that our JIRA is already connected to the Github (see attached screenshot).![image (13).png](https://community.atlassian.com/t5/image/serverpage/image-id/141564i4B88C7D7F3FA676B/image-size/large?v=v2&px=999 "image (13).png")But I'm not sure how to use this integration in creating the automation rule that will move JIRA issues to a certain state e.g. "Awaiting Code Review" or "QA" when PR gets set to "Request Review" or "Approved" in Github.

I would really appreciate if you share any additional info on that

TIA,

Olga


Tags: webhook