Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,555,308
Community Members
 
Community Events
184
Community Groups

How to fail incoming Webhooks JQL search gracefully?

Hi,

I have been writing some project automation and using incoming Webhooks from GitHub which is working great but I have one minor non fatal problem.

To find the issue number I use the JQL search feature (Issues provided by running the following JQL search) that extracts the issue from the webhookData.
However in many cases the data will not contain an issue number and I would like the automation to just ignore this instead of failing with an error.

When the JQL search returns an empty key I get the following error:

Incoming webhook trigger failed to run JQL search:"(key = "") AND (project in (xxxx))" - The issue key '' for field 'key' is invalid.

And the rule fails with Some Errors but I would rather just fail the rule gracefully as this is a known case.

Is there anyway to achieve this and make an empty JQL search in the Webhooks just stop running the rule?

 

Thanks for any assistance.

3 answers

0 votes
Artem Artemev
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Mar 08, 2023 • edited Mar 09, 2023

I had exactly that problem recently, and i'm ready to share what i've came up with.

1. Create a system task that is reachable from your automation context and make it as hidden as possible, so people won't see it and won't delete it. The ID of that task will be the default one

2. In the JQL rule to extract ticket ids from the payload, use the following `key = {{webhookData.action.substring(0,0).concat("@@").concat(webhookData.pull_request.title).concat("@@").concat(webhookData.pull_request.head.ref).concat("@@DEV-84@@DEV-84").match("@@.*?([a-zA-Z]+-\d+)").first}}`

Here, DEV-84 is the ID of your system ticket that you've just created, replace it with your own system ticket ID. This rule is also able to detect a ticket ID from the branch name as well as from the PR title, the title has a priority.

3. As your first component after the webhook, create an IF condition with JQL rule `key != DEV-84`, which basically stop the execution if the ticket is is the "system" one.

4. Add all your other rules after it

That way, if the ticket is not found in PR or branch, the system one will be used instead. Any operation for the system ticket is gracefully ignored.

@Bill Sheboy sure hopefully this gives more context:

Heres the rule to find the issue in the webhook pull_request title...

Screenshot 2021-05-12 at 10.03.59.png

And the audit log if no issue is found the key is then empty so it shows with "Some errors"...

Screenshot 2021-05-12 at 10.04.23.png

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 12, 2021

Yup, that looks like a known issue: https://codebarrel.atlassian.net/browse/AUT-1483

Hmmm... I wonder, if you use the "No issues from the webhook" option, and then later use the same JQL to check the webhookData and populate a Lookup Issues action.  Then you could check if the count is zero and fail gracefully.

Hi, I'm experiencing the same issue with webhooks driven by GitHub events.

I tried to follow up on your suggestion Bill, unfortunately the tasks in my automation require the Issue to be set by the webhook trigger rather than an explicit 'Lookup' later on.

Cheers,

Rich
Screenshot 2022-06-07 074956.png

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jun 07, 2022 • edited

Hi @Rich Tamblyn -- Welcome to the Atlassian Community!

I recommend posting a new question, with images of your complete rule and audit log details, and link back to this post.  Otherwise only the people who are following this thread will see it to offer suggestions.

Until then...that error is telling you that your Transition Issue component needs an issue to process, and so if your trigger is Incoming webhook, you will need to do something like branch on JQL from the webhook data prior to the transition, or get the data directly from the trigger (as shown above).  For an example of the branch technique:

  • trigger: incoming webhook
  • branch: on some JQL built using data from the webhook to get the issue
    • action: transition issue

 

Kind regards,
Bill

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 11, 2021

Hi @Iain Simpson 

Would you please provide an image of your automation rule and audit log?  That may provide more context for the community to offer ideas.  Thanks!

Best regards,

Bill

Suggest an answer

Log in or Sign up to answer