BitBucket Branch Source Plugin not triggering builds from Post Webhooks PR event

339 views
Skip to first unread message

Young Lee

unread,
Nov 22, 2017, 2:02:11 PM11/22/17
to Jenkins Users
Hi,

I been tracing the bitbucket branch source plugin thru the Intellij IDE debugger and am in need of help to understand why PR is not triggering builds.

Here is my setup:

   bitbucket server: version 4.14.11
   Post Webhooks for Bitbucket: v1.6.0
   bitbucket branch source plugin:  cloned from the github. (https://github.com/jenkinsci/bitbucket-branch-source-plugin.git)

Jenkins Job setup:

   BitBucket Team/Project (see attached screenshot for configuration)
   

I can see the PR events getting processed on Jenkins (below) when I update the PR branch, but the job is not getting scheduled.

I really would appreciate some pointers on what to look for tracing the code.  I am guessing that the process method on line 661 inside the retrievePullRequest should be returning `true` to schedule a build.  When I trace the code that method seems to return false.

[Wed Nov 22 10:22:18 PST 2017] Received com.cloudbees.jenkins.plugins.bitbucket.hooks.PushHookProcessor$1 UPDATED event from 127.0.0.1 ⇒ http://localhost:8080/jenkins/bitbucket-scmsource-hook/notify with timestamp Wed Nov 22 10:22:18 PST 2017
Connecting to http://localhost:7990 using admin/****** (admin)
Repository type: Git
Looking up OP/ovn2 for branches
Checking branch test_web_hook from OP/ovn2
Checking branch master from OP/ovn2

  2 branches were processed
Looking up OP/ovn2 for pull requests
Checking PR-1 from OP/ovn2 and branch test_web_hook

  1 pull requests were processed
[Wed Nov 22 10:24:12 PST 2017] com.cloudbees.jenkins.plugins.bitbucket.hooks.PushHookProcessor$1 UPDATED event from 127.0.0.1 ⇒ http://localhost:8080/jenkins/bitbucket-scmsource-hook/notify with timestamp Wed Nov 22 10:22:18 PST 2017 processed in 1 min 53 sec

Screen Shot 2017-11-22 at 10.56.22 AM.jpg

Dan Tran

unread,
Nov 22, 2017, 5:50:05 PM11/22/17
to Jenkins Users
have a looks at this issue, may help

-D

Dan Tran

unread,
Nov 22, 2017, 5:50:18 PM11/22/17
to Jenkins Users

Young Lee

unread,
Nov 22, 2017, 8:43:23 PM11/22/17
to Jenkins Users
Thanx,

That helps,

I can see the PUSH event when I push a new branch

 git push --set-upstream origin webhook1


Push Event from webhook

{"actor":{"username":"admin","displayName":"admin"},"repository":{"scmId":"git","project":{"key":"OP","name":"Open VisaNet"},"slug":"ovn2","links":{"self":[{"href":"http://localhost:7990/projects/OP/repos/ovn2/browse"}]},"public":false,"fullName":"OP/ovn2","owner":{"username":"OP","displayName":"OP"},"ownerName":"OP"},"push":{"changes":[{"created":true,"closed":false,"new":{"type":"branch","name":"webhook","target":{"type":"commit","hash":"9cc7446788a3e66d29a69e67cdc0ee3a519535d5"}},"old":null}]}}

However I am not seeing PullRequest event when I create a PR from the stash.  Can this be a problem ?  Also where can I find the webhook events in the stash logs?

On Wednesday, November 22, 2017 at 2:50:18 PM UTC-8, Dan Tran wrote:
https://github.com/Eernie/bitbucket-webhooks-plugin/issues/72


Young Lee

unread,
Nov 23, 2017, 1:47:00 PM11/23/17
to Jenkins Users
Hi,

I believe the new feature introduced in the Post Webhooks for Bitbucket version 1.6.0 to "add support for ignoring branches" in advertently is filtering all PullRequestEvents and it is not sent out to the registered webhooks.

Version 1.5.2 does send PullRequestEvents.

The following changes in the PullRequestListener seems to have caused this regression

 if(event instanceof BitbucketPushEvent && pushEventService.isValidEvent((BitbucketPushEvent) event, webHookConfiguration))
            {
                try (CloseableHttpResponse response = httpClient.execute(post))
                {
                    int statusCode = response.getStatusLine().getStatusCode();
                    if (statusCode >= 400)
                    {
                        LOGGER.error(
                                "[repo: {}]| Something went wrong while posting (response code:{}) the following body to webhook: [{}({})] \n{}",
                                repo,
                                statusCode,
                                webHookConfiguration.getTitle(),
                                webHookConfiguration.getURL(),
                                body);
                    }
                }
                catch (IOException e)
                {
                    LOGGER.error(
                            "[repo: {}]| Something went wrong while posting the following body to webhook: [{}({})] \n{}",
                            repo,
                            webHookConfiguration.getTitle(),
                            webHookConfiguration.getURL(),
                            body,
                            e);
                }
            }

Joseph P

unread,
Nov 24, 2017, 4:34:09 AM11/24/17
to Jenkins Users
Good catch, I'll look into it

Joseph P

unread,
Nov 28, 2017, 5:04:56 AM11/28/17
to Jenkins Users
Released a fix for PR events not working: https://marketplace.atlassian.com/plugins/nl.topicus.bitbucket.bitbucket-webhooks/versions#b100600100

Next time please post the issue on GitHub, https://github.com/Eernie/bitbucket-webhooks-plugin/issues
I rarely read the Jenkins users threads, sorry.


Den torsdag den 23. november 2017 kl. 19.47.00 UTC+1 skrev Young Lee:
Reply all
Reply to author
Forward
0 new messages