Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-63468

Bitbucket plugin unable to parse push/test connection bitbucket webhook json payload

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Blocker
    • Resolution: Fixed
    • Component/s: bitbucket-plugin
    • Labels:
      None
    • Environment:
      Jenkins 2.238
      Bitbucket plugin 1.1.11 & 1.1.20
    • Similar Issues:
    • Released As:
      1.1.25

      Description

      Recently, we upgraded Bitbucket server 5.13 to 7.4.1. All automated Bitbucket webhooks jobs stopped triggering. Surprisingly, we are getting below exception in Jenkins logs.

      net.sf.json.JSONException: JSONObject["user"] not found.

              at net.sf.json.JSONObject.getString(JSONObject.java:2040)

              at com.cloudbees.jenkins.plugins.BitbucketPayloadProcessor.processPostServicePayload(BitbucketPayloadProcessor.java:178)

              at com.cloudbees.jenkins.plugins.BitbucketPayloadProcessor.processPayload(BitbucketPayloadProcessor.java:42)

              at com.cloudbees.jenkins.plugins.BitbucketHookReceiver.doIndex(BitbucketHookReceiver.java:54)

              at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)

      So we upgraded Bitbucket plugin with 1.1.20 but still getting same issue in Jenkins.

        Attachments

          Activity

          Hide
          tzach_solomon Tzach Solomon added a comment -

          Chandan Kumar please refer to https://support.cloudbees.com/hc/en-us/articles/115000051112-Bitbucket-Webhooks-Troubleshooting to enable logs so and pate here the web hook POST JSON request. Thanks

          Show
          tzach_solomon Tzach Solomon added a comment - Chandan Kumar please refer to  https://support.cloudbees.com/hc/en-us/articles/115000051112-Bitbucket-Webhooks-Troubleshooting  to enable logs so and pate here the web hook POST JSON request. Thanks
          Hide
          tzach_solomon Tzach Solomon added a comment -
          Show
          tzach_solomon Tzach Solomon added a comment - Chandan Kumar ?
          Hide
          ckmca Chandan Kumar added a comment -

          Thanks Tzach for the response. I just tried to test a connection for jenkins webhooks. Kindly refer the screenshot for the json request for the test connection. We are using Atlassian Bitbucket server webhooks 7.4.1 plugin from the Bitbucket side and Bitbucket 1.1.20 plugin from the Jenkins side.

          Show
          ckmca Chandan Kumar added a comment - Thanks Tzach for the response. I just tried to test a connection for jenkins webhooks. Kindly refer the screenshot for the json request for the test connection. We are using Atlassian Bitbucket server webhooks 7.4.1 plugin from the Bitbucket side and Bitbucket 1.1.20 plugin from the Jenkins side.
          Hide
          tzach_solomon Tzach Solomon added a comment -

          Chandan Kumar can you please try the latest version (above 1.1.23)?

          Show
          tzach_solomon Tzach Solomon added a comment - Chandan Kumar can you please try the latest version (above 1.1.23)?
          Hide
          ckmca Chandan Kumar added a comment -

          Thanks Tzach.After upgrading with 1.1.23 test connections returning 200 status however jenkins jobs are not triggering post pushing the code in Bitbucket repos. Kindly refer Request details below.

          Request URL:  http://172.31.4.160:80/bitbucket-hook/

          Request Headers: 

          X-Request-Id: ebd1fa30-22df-4522-af8c-7c08951a428b
          Content-Type: application/json; charset=utf-8
          X-Event-Key: repo:refs_changed

          Request Body:
          {"eventKey":"repo:refs_changed","date":"2020-09-02T13:37:43+0100","actor":{"name":"chandan.kumar","emailAddress":"Chandan.K@currenciesdirect.com","id":210,"displayName":"Chandan Kumar","active":true,"slug":"chandan.kumar","type":"NORMAL","links":{"self":[

          {"href":"https://repos.currenciesdirect.com:8443/users/chandan.kumar"}

          ]}},"repository":{"slug":"testwebapp","id":167,"name":"TestWebApp","hierarchyId":"68172ff8baea123355b9","scmId":"git","state":"AVAILABLE","statusMessage":"Available","forkable":true,"project":{"key":"DEVOPS","id":263,"name":"Devops","description":"Devops projects","public":false,"type":"NORMAL","links":{"self":[

          {"href":"https://repos.currenciesdirect.com:8443/projects/DEVOPS"}

          ]}},"public":false,"links":{"clone":[

          {"href":"ssh://git@repos.currenciesdirect.com:7999/devops/testwebapp.git","name":"ssh"}

          ,{"href":"https://repos.currenciesdirect.com:8443/scm/devops/testwebapp.git","name":"http"}],"self":[\{"href":"https://repos.currenciesdirect.com:8443/projects/DEVOPS/repos/testwebapp/browse"}]}},"changes":[{"ref":

          {"id":"refs/heads/master","displayId":"master","type":"BRANCH"}

          ,"refId":"refs/heads/master","fromHash":"0ac25b1051facb34e1353e3ef7452cba71b7b6a4","toHash":"ee5df21c6c268e88f83f36593acb8946842b151c","type":"UPDATE"}]}

          Show
          ckmca Chandan Kumar added a comment - Thanks Tzach.After upgrading with 1.1.23 test connections returning 200 status however jenkins jobs are not triggering post pushing the code in Bitbucket repos. Kindly refer Request details below. Request URL:  http://172.31.4.160:80/bitbucket-hook/ Request Headers:  X-Request-Id: ebd1fa30-22df-4522-af8c-7c08951a428b Content-Type: application/json; charset=utf-8 X-Event-Key: repo:refs_changed Request Body: {"eventKey":"repo:refs_changed","date":"2020-09-02T13:37:43+0100","actor":{"name":"chandan.kumar","emailAddress":"Chandan.K@currenciesdirect.com","id":210,"displayName":"Chandan Kumar","active":true,"slug":"chandan.kumar","type":"NORMAL","links":{"self":[ {"href":"https://repos.currenciesdirect.com:8443/users/chandan.kumar"} ]}},"repository":{"slug":"testwebapp","id":167,"name":"TestWebApp","hierarchyId":"68172ff8baea123355b9","scmId":"git","state":"AVAILABLE","statusMessage":"Available","forkable":true,"project":{"key":"DEVOPS","id":263,"name":"Devops","description":"Devops projects","public":false,"type":"NORMAL","links":{"self":[ {"href":"https://repos.currenciesdirect.com:8443/projects/DEVOPS"} ]}},"public":false,"links":{"clone":[ {"href":"ssh://git@repos.currenciesdirect.com:7999/devops/testwebapp.git","name":"ssh"} ,{"href":"https://repos.currenciesdirect.com:8443/scm/devops/testwebapp.git","name":"http"}],"self": [\{"href":"https://repos.currenciesdirect.com:8443/projects/DEVOPS/repos/testwebapp/browse"}] }},"changes":[{"ref": {"id":"refs/heads/master","displayId":"master","type":"BRANCH"} ,"refId":"refs/heads/master","fromHash":"0ac25b1051facb34e1353e3ef7452cba71b7b6a4","toHash":"ee5df21c6c268e88f83f36593acb8946842b151c","type":"UPDATE"}]}
          Hide
          ckmca Chandan Kumar added a comment -

          Hi Tzach,

          All the CI jobs blocked due to this issue. I already sent the request payload in my previous comment. Can you please take a look and help to resolve this issue. Please let me know if you need more details.

          Show
          ckmca Chandan Kumar added a comment - Hi Tzach, All the CI jobs blocked due to this issue. I already sent the request payload in my previous comment. Can you please take a look and help to resolve this issue. Please let me know if you need more details.
          Hide
          tzach_solomon Tzach Solomon added a comment -

          Hi Chandan Kumar,

          Can you please see https://support.cloudbees.com/hc/en-us/articles/115000051112-Bitbucket-Webhooks-Troubleshooting and paste in the logs to understand why it does not trigger the jobs.

          Show
          tzach_solomon Tzach Solomon added a comment - Hi Chandan Kumar , Can you please see https://support.cloudbees.com/hc/en-us/articles/115000051112-Bitbucket-Webhooks-Troubleshooting and paste in the logs to understand why it does not trigger the jobs.
          Hide
          tzach_solomon Tzach Solomon added a comment -

          Chandan Kumar just to be on the same page, i'm waiting for your logs

          Show
          tzach_solomon Tzach Solomon added a comment - Chandan Kumar just to be on the same page, i'm waiting for your logs
          Hide
          ckmca Chandan Kumar added a comment -

          Sorry Tzach. After enabling the logs. We are getting below error logs in jenkins.

          2020-09-08 09:50:25.544+0000 [id=899] INFO c.c.j.p.BitbucketPayloadProcessor#processPayload: Processing old POST service payload
          2020-09-08 09:50:25.545+0000 [id=899] INFO c.c.j.p.BitbucketPayloadProcessor#processPostServicePayload: Received commit hook notification for {"slug":"testwebapp","id":167,"name":"TestWebApp","hierarchyId":"68172ff8baea123355b9","scmId":"git","state":"AVAILABLE","statusMessage":"Available","forkable":true,"project":

          {"key":"DEVOPS","id":263,"name":"Devops","description":"Devops projects","public":false,"type":"NORMAL"}

          ,"public":false}
          2020-09-08 09:50:25.547+0000 [id=899] WARNING o.e.j.s.h.ContextHandler$Context#log: Error while serving http://172.31.4.160/bitbucket-hook/
          net.sf.json.JSONException: JSONObject["user"] not found.
          at net.sf.json.JSONObject.getString(JSONObject.java:2040)
          at com.cloudbees.jenkins.plugins.BitbucketPayloadProcessor.processPostServicePayload(BitbucketPayloadProcessor.java:185)
          at com.cloudbees.jenkins.plugins.BitbucketPayloadProcessor.processPayload(BitbucketPayloadProcessor.java:49)
          at com.cloudbees.jenkins.plugins.BitbucketHookReceiver.doIndex(BitbucketHookReceiver.java:54)

          Show
          ckmca Chandan Kumar added a comment - Sorry Tzach. After enabling the logs. We are getting below error logs in jenkins. 2020-09-08 09:50:25.544+0000 [id=899] INFO c.c.j.p.BitbucketPayloadProcessor#processPayload: Processing old POST service payload 2020-09-08 09:50:25.545+0000 [id=899] INFO c.c.j.p.BitbucketPayloadProcessor#processPostServicePayload: Received commit hook notification for {"slug":"testwebapp","id":167,"name":"TestWebApp","hierarchyId":"68172ff8baea123355b9","scmId":"git","state":"AVAILABLE","statusMessage":"Available","forkable":true,"project": {"key":"DEVOPS","id":263,"name":"Devops","description":"Devops projects","public":false,"type":"NORMAL"} ,"public":false} 2020-09-08 09:50:25.547+0000 [id=899] WARNING o.e.j.s.h.ContextHandler$Context#log: Error while serving http://172.31.4.160/bitbucket-hook/ net.sf.json.JSONException: JSONObject ["user"] not found. at net.sf.json.JSONObject.getString(JSONObject.java:2040) at com.cloudbees.jenkins.plugins.BitbucketPayloadProcessor.processPostServicePayload(BitbucketPayloadProcessor.java:185) at com.cloudbees.jenkins.plugins.BitbucketPayloadProcessor.processPayload(BitbucketPayloadProcessor.java:49) at com.cloudbees.jenkins.plugins.BitbucketHookReceiver.doIndex(BitbucketHookReceiver.java:54)
          Hide
          tzach_solomon Tzach Solomon added a comment -

          Chandan Kumar added support for x-event-key repo:refs_changed in 1.1.25. Notice you might also still need the override URL feature which was introduced in version 1.1.19 (check BitbucketJobProbe log if you have problems matching)

          Example for logs with override feature:

          Sep 08, 2020 7:47:17 PM FINE com.cloudbees.jenkins.plugins.BitbucketJobProbe
           Trying to match https://tzachs/tzachs/tzach.git.git<-->devops/testwebapp
          
          Sep 08, 2020 7:47:17 PM FINE com.cloudbees.jenkins.plugins.BitbucketJobProbe
           Trying to match using override Repository URL devops/testwebapp<-->devops/testwebapp
          
          Sep 08, 2020 7:47:17 PM INFO com.cloudbees.jenkins.plugins.BitbucketJobProbe triggerMatchingJobs
          
           Triggering BitBucket job tzach.git
          Show
          tzach_solomon Tzach Solomon added a comment - Chandan Kumar added support for x-event-key repo:refs_changed in 1.1.25. Notice you might also still need the override URL feature which was introduced in version 1.1.19 (check BitbucketJobProbe log if you have problems matching) Example for logs with override feature: Sep 08, 2020 7:47:17 PM FINE com.cloudbees.jenkins.plugins.BitbucketJobProbe Trying to match https: //tzachs/tzachs/tzach.git.git<-->devops/testwebapp Sep 08, 2020 7:47:17 PM FINE com.cloudbees.jenkins.plugins.BitbucketJobProbe Trying to match using override Repository URL devops/testwebapp<-->devops/testwebapp Sep 08, 2020 7:47:17 PM INFO com.cloudbees.jenkins.plugins.BitbucketJobProbe triggerMatchingJobs Triggering BitBucket job tzach.git
          Hide
          tzach_solomon Tzach Solomon added a comment -

          Chandan Kumar feel free to re-open if does not work but please first try me at the comments section

          Show
          tzach_solomon Tzach Solomon added a comment - Chandan Kumar feel free to re-open if does not work but please first try me at the comments section
          Hide
          ckmca Chandan Kumar added a comment -

          Thank you Tzach. It's working fine for me. Appreciate for your help.

          Show
          ckmca Chandan Kumar added a comment - Thank you Tzach. It's working fine for me. Appreciate for your help.
          Hide
          tzach_solomon Tzach Solomon added a comment -

          Sure thing Chandan Kumar

          Show
          tzach_solomon Tzach Solomon added a comment - Sure thing Chandan Kumar
          Hide
          ckmca Chandan Kumar added a comment -

          Hi Tzach,

          In my dev jenkins environment 1.1.25 version available but other environments of jenkins, it's still showing Bitbucket 1.1.24 version. Can you please assist what went wrong.

          Show
          ckmca Chandan Kumar added a comment - Hi Tzach, In my dev jenkins environment 1.1.25 version available but other environments of jenkins, it's still showing Bitbucket 1.1.24 version. Can you please assist what went wrong.
          Hide
          tzach_solomon Tzach Solomon added a comment -

          Chandan Kumar that is out of my scope but I'm guessing some caching or something like that.
          have you tried the "Check Now" button at the bottom of the page?

          Show
          tzach_solomon Tzach Solomon added a comment - Chandan Kumar that is out of my scope but I'm guessing some caching or something like that. have you tried the "Check Now" button at the bottom of the page?

            People

            Assignee:
            tzach_solomon Tzach Solomon
            Reporter:
            ckmca Chandan Kumar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: