Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,367,567
Community Members
 
Community Events
168
Community Groups

How to create Jira Automation Rule using a Wedhook "Pull Request Review" from Github

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

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

4 answers

1 vote
Darryl Lee Community Leader Apr 16, 2021

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 documentation.)

Darryl Lee Community Leader Apr 16, 2021

OH. Reading the article How to integrate Jira and GitHub using Automation for Jira, @Simmo 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".

Darryl Lee Community Leader Apr 16, 2021

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.

Thanks for your response @Darryl Lee !!

Actually, I was using the @Simmo article as a base for creating conditions in my rule and found very helpful - Thanks @Simmo !!

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

Simmo Atlassian Team Apr 18, 2021

Hi @Olga Buslovich,

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 and log out the webhook data. That will show you everything you can access.

Cheers,

Simeon.

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 

BTW, @Simmo  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

0 votes
Darryl Lee Community Leader Apr 27, 2021

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?

Hi @Darryl Lee ,

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).pngBut 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

Thanks for your reply @Simmo !!

Now that I know that there are no access permissions involve  then I've moved on and tried the @Darryl Lee  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

Simmo Atlassian Team Apr 18, 2021

Hi @Olga Buslovich , could you provide an example of what you're getting? That's the easiest way to figure it out.

@Simmo  Thanks for looking :)lga

Simmo Atlassian Team Apr 18, 2021

Hi @Olga Buslovich

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.

Like Olga Buslovich likes this

Thank YOU @Simmo !!

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

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events