It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Webhook is not working as exepected

pankaj kumar Jul 09, 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 Levinson Atlassian Team Jul 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

pankaj kumar Jul 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 Levinson Atlassian Team Jul 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?

pankaj kumar Jul 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 Levinson Atlassian Team Jul 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

pankaj kumar Jul 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 Apr 12, 2019 • edited

EDIT: not actually our issue, moving

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder

...ipe.sh :  #!/bin/bash source "$(dirname "$0")/common.sh" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

1,605 views 1 18
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you