Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Is there an order of events delivered by a webhook?

Øystein Walle December 5, 2023

Hi!

I have set up webooks for the "repo:push" and "pullrequest:updated" events. (Other "pullrequest" events too, but not relevant to the question I think).

I want to act on the update of a pull request by checking the commit(s) in various ways. Both the "repo:push" and "pullrequest:updated" events are sent off when a pull request is updated, but only the "repo:push" event contains information about the old value of the updated ref. The two events seem to always be delievered in separate payloads.

Is there a way to "tie" these two events together? For example, is one guaranteed to be delivered before the other? Or is there some ID in the payloads that are the same? From what I can see "repo:push" is always delivered first, but I'm not sure if that's reliable.

Thanks!

1 answer

1 accepted

0 votes
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 7, 2023

Hello @Øystein Walle and thank you for reaching out to Community! 

The webhooks for different events are indeed sent in different payloads. 

I would not rely on the order of the delivery to link the payload of both the events together, as they are separate requests, and Bitbucket will attempt to send each webhook 3 times, it's not always granted that one event will be delivered before the other.

In your case, as you want to link the payload of a repo:push with a pullrequest:updated, I would suggest checking the commit hash in each of the payloads.

In the pullrequest:updated you will have the head commit of the source branch in the pullrequest.source.commit.hash field. This can be compared with the push.changes.new.target.hash field of the repo:push event, as it will contain the commit that triggered the event.

You could use the commit hashes as described above to link the content of each payload and get the information you are looking for.

For additional details on the webhook payload of each event, the following documentation may also be of help : 

Thank you, @Øystein Walle !

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events