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

Webhook is not working as exepected

Pankaj2204 July 9, 2018

Issue: I have a web hook for firing off a build when a pull request is merged. my issue is that the web hook is firing the build when the Pull request is created. this is causing the build to fail since the branch that is being build is from the previous build. I'm not sure why it is firing the hook when the PR is created. I only have "Pull request merged" checked.

1 answer

0 votes
Aaron
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 10, 2018

Hello Pankaj,

 

Welcome to the Atlassian Community!

How are you confirming that the webhook is firing on the PR being created? If you are only checking to see if the build starts, is it possible that your CI is checking for PRs on top of the Webhook? More importantly, when you do merge the PR, does the webhook fire as expected? A quick test would be to just disable the webhook and open a PR to see if a build starts (and fails). Off-hand, I'm not sure exactly what else it could be. I assume you are using the webhooks built-in to Bitbucket?

 

Regards,
Aaron Levinson
Dev Tools Support Engineer

Pankaj2204 July 10, 2018

The web hook we created is pretty strait forward. My CI is not checking for anything. my web hook call a URL on jenkins which fires off a build. the issue is that if the build is triggered when the PR is created, the same build will fail when it is merged since the version is the same

Aaron
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 10, 2018

Could we get some confirmation on some of the questions I asked previously?

  1. Is this Webhook being created from the Bitbucket Webhook tab in the repository settings?
  2. If you disable the webhook, can you confirm the behavior of Bitbucket with Jenkins (or what we should expect to be no behavior at all)?
  3. You said "the build will fail when it is merged" does that mean you attempted to do so or is this speculation (as in you confirmed that the hook is sent on merge as well as created)?

Also if you are able to upload any screenshots of how things are configured on both the Bitbucket and Jenkins side, that would be appreciated. I wasn't able to reproduce this behavior. I am using the latest version of Bitbucket Server of 5.11.1 and the latest version of Jenkins with 2.121.1. What version of Bitbucket are you using (or are you using cloud) and what version of Jenkins are you working with?

Pankaj2204 July 11, 2018

Hi Aaron,

Below is answer for your query

Is this Webhook being created from the Bitbucket Webhook tab in the repository settings? Yes - I am using Post Webhook under repository settings
If you disable the webhook, can you confirm the behavior of Bitbucket with Jenkins (or what we should expect to be no behavior at all)? - Yes it is working fine
You said "the build will fail when it is merged" does that mean you attempted to do so or is this speculation (as in you confirmed that the hook is sent on merge as well as created)? Yes it is sending for both the event but we want built should be trigger only when merge happen to latest releas branch.

Aaron
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 11, 2018

If you are doing the Post Webhooks then that isn't the default Webhooks that is bundled with Bitbucket. That is a third part Post Webhooks plugin. But I wasn't able to reproduce the issue with that plugin either. If you go the Webhooks section instead of Post Webhooks and try to create one there do you see the same issue? Could you also confirm what version of Bitbucket you are using?

image.png

Pankaj2204 July 11, 2018

We are on bitbucket 5.9. I also looked on webhook but the issue is we are not getting configuration on branch level. As I mentioned before I need build should be trigger when pr will merge in latest release branch.

 

Thanks,

Pankaj

Simon Storr April 12, 2019

EDIT: not actually our issue, moving

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events