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

bitbucket-plugin not recognising self-hosted repo from trigger payload in multi-branch pipelines

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Fixed but Unreleased (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: bitbucket-plugin
    • Labels:
      None
    • Environment:
      Jenkins: 2.277.4
      bitbucket-plugin: 1.1.27

      Job type: multi-branch pipeline
    • Similar Issues:
    • Released As:
      1.1.28

      Description

      Summary: the Bitbucket plugin is not triggering builds when receiving the Git push payload from Bitbucket server.

      Details:

      When a payload is received the following is logged (I set this message to INFO):

      2021-05-17 05:44:22.687+0000 [id=12]    INFO    c.c.j.plugins.BitbucketJobProbe#triggerMatchingJobs: SCM [example] doesn't match remote repo [prj/example]
      

      Firstly there appears to be no config option to override the Bitbucket push URL in a multi-branch pipeline job (at least not in the UI). The single branch pipeline does seem to have such an option.

      Now the Bitbucket Server "project" key is set in the job configuration and it then lists the actual repository just fine. But no matter what I try I can't get the Bitbucket plugin to "see" the repo as "prj/example" OR get the SCM configuration to use "prj/example".

      The project key setting is present in the job config but I don't see a way to make the SCM source combine it to be "prj/example".

        Attachments

          Activity

          Hide
          tzach_solomon Tzach Solomon added a comment -

          Friedrich Clausen changed in 1.1.29 

          Show
          tzach_solomon Tzach Solomon added a comment - Friedrich Clausen  changed in 1.1.29 
          Hide
          ftclausen Friedrich Clausen added a comment -

          Yes, this works with the override UI. Thank you for fixing this so quickly!

          Perhaps one suggestion for next release: UI option for "Build when a change is pushed to BitBucket" says "Override Repository URL". However, for me, I had to put in the repository location not an actual URL; for example 'prj/example' shown as image for context:

          It could maybe be worded as "Override Repository URL or Path". Maybe a help text that could say something like "Self-hosted Bitbucket users may need to set this to '<project key>/<repo' for example 'prj/example-repo'"

          Show
          ftclausen Friedrich Clausen added a comment - Yes, this works with the override UI. Thank you for fixing this so quickly! Perhaps one suggestion for next release: UI option for "Build when a change is pushed to BitBucket" says "Override Repository URL". However, for me, I had to put in the repository location not an actual URL; for example 'prj/example' shown as image for context: It could maybe be worded as "Override Repository URL or Path". Maybe a help text that could say something like "Self-hosted Bitbucket users may need to set this to '<project key>/<repo' for example 'prj/example-repo'"
          Hide
          tzach_solomon Tzach Solomon added a comment -

          Friedrich Clausen 
          Thanks for the header and body JSON. It really helped me reproducing the problem.
          I've added a UI in multi branch and tested to the best of my ability.
          Please also check and LMK if it works. 

          Thanks

          Show
          tzach_solomon Tzach Solomon added a comment - Friedrich Clausen   Thanks for the header and body JSON. It really helped me reproducing the problem. I've added a UI in multi branch and tested to the best of my ability. Please also check and LMK if it works.  Thanks
          Hide
          ftclausen Friedrich Clausen added a comment -

          Running ngrep capturing on the Jenkins port it receives the following:

          interface: lo0 (127.0.0.0/255.0.0.0)
          filter: (ip or ip6) and ( port 8080 )
          #####
          T 127.0.0.1:63025 -> 127.0.0.1:8080 [AP]
          POST /bitbucket-hook/ HTTP/1.1.
          X-Event-Key: repo:refs_changed.
          Accept: */*.
          X-Request-Id: 8157a692-5664-44ee-bdcb-d5e6ab123bfa.
          Content-Type: application/json; charset=UTF-8.
          Via: 1.1 localhost (Apache-HttpClient/4.5.5 (cache)).
          Content-Length: 1149.
          Host: host.docker.internal:8080.
          Connection: Keep-Alive.
          User-Agent: Atlassian HttpClient 2.1.0 / Bitbucket-7.6.3 (7006003) / Default.
          .
          {"eventKey":"repo:refs_changed","date":"2021-05-17T23:12:02+0000","actor":{"name":"fclausen","emailAddress":"friedrich.clausen@blackboard.com","id":1,"displayName":"Friedrich Clausen","active":true,"slug":"fclausen","type":"NORMAL","links":{"self":[{"href":"http://host.docker.internal:7990/users/fclausen"}]}},"repository":{"slug":"example","id":12,"name":"example","hierarchyId":"000a8aa7f174baf248ce","scmId":"git","state":"AVAILABLE","statusMessage":"Available","forkable":true,"project":{"key":"PRJ","id":42,"name":"PROJECT","public":false,"type":"NORMAL","links":{"self":[{"href":"http://host.docker.internal:7990/projects/PRJ"}]}},"public":false,"links":{"clone":[{"href":"http://host.docker.internal:7990/scm/prj/example.git","name":"http"},{"href":"ssh://git@host.docker.internal:7999/prj/example.git","name":"ssh"}],"self":[{"href":"http://host.docker.internal:7990/projects/PRJ/repos/example/browse"}]}},"changes":[{"ref":{"id":"refs/heads/master","displayId":"master","type":"BRANCH"},"refId":"refs/heads/master","fromHash":"a2b8922d6dccf623e17c7eecb25074c6c0
          #
          T 127.0.0.1:63025 -> 127.0.0.1:8080 [AP]
          f569e9","toHash":"0c6ae17586daf40ae84cc8ed02c9ea5d50db78e1","type":"UPDATE"}]}
          ###
          T 127.0.0.1:8080 -> 127.0.0.1:63025 [AP]
          HTTP/1.1 200 OK.
          Date: Mon, 17 May 2021 23:12:03 GMT.
          X-Content-Type-Options: nosniff.
          Content-Length: 0.
          Server: Jetty(9.4.39.v20210325).
          .
          

          For convenience, the formatted payload above is:

          {
            "eventKey": "repo:refs_changed",
            "date": "2021-05-17T23:12:02+0000",
            "actor": {
              "name": "fclausen",
              "emailAddress": "friedrich.clausen@blackboard.com",
              "id": 1,
              "displayName": "Friedrich Clausen",
              "active": true,
              "slug": "fclausen",
              "type": "NORMAL",
              "links": {
                "self": [
                  {
                    "href": "http://host.docker.internal:7990/users/fclausen"
                  }
                ]
              }
            },
            "repository": {
              "slug": "example",
              "id": 12,
              "name": "example",
              "hierarchyId": "000a8aa7f174baf248ce",
              "scmId": "git",
              "state": "AVAILABLE",
              "statusMessage": "Available",
              "forkable": true,
              "project": {
                "key": "PRJ",
                "id": 42,
                "name": "PROJECT",
                "public": false,
                "type": "NORMAL",
                "links": {
                  "self": [
                    {
                      "href": "http://host.docker.internal:7990/projects/PRJ"
                    }
                  ]
                }
              },
              "public": false,
              "links": {
                "clone": [
                  {
                    "href": "http://host.docker.internal:7990/scm/prj/example.git",
                    "name": "http"
                  },
                  {
                    "href": "ssh://git@host.docker.internal:7999/prj/example.git",
                    "name": "ssh"
                  }
                ],
                "self": [
                  {
                    "href": "http://host.docker.internal:7990/projects/PRJ/repos/example/browse"
                  }
                ]
              }
            },
            "changes": [
              {
                "ref": {
                  "id": "refs/heads/master",
                  "displayId": "master",
                  "type": "BRANCH"
                },
                "refId": "refs/heads/master",
                "fromHash": "a2b8922d6dccf623e17c7eecb25074c6c0f569e9",
                "toHash": "0c6ae17586daf40ae84cc8ed02c9ea5d50db78e1",
                "type": "UPDATE"
              }
            ]
          }
          

          Finally the FINEST logging shows (minus timestamps)

          Considering candidate job bitbucket-single-branch-pipeline
          bitbucket-single-branch-pipeline hasnt BitBucketTrigger set
          No SCM configuration was found!
          Now checking SCMSourceOwners/multiBranchProjects
          Considering candidate scmSourceOwner example
          Considering candidate scmSource com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource{id='e30d68a9-fddc-49ad-af73-53e1dbb3552c'}
          SCMSource is [BitbucketSCMSource] which is not supported
          SCM [example] doesn't match remote repo [prj/example]
          
          Show
          ftclausen Friedrich Clausen added a comment - Running ngrep capturing on the Jenkins port it receives the following: interface: lo0 (127.0.0.0/255.0.0.0) filter: (ip or ip6) and ( port 8080 ) ##### T 127.0.0.1:63025 -> 127.0.0.1:8080 [AP] POST /bitbucket-hook/ HTTP/1.1. X-Event-Key: repo:refs_changed. Accept: */*. X-Request-Id: 8157a692-5664-44ee-bdcb-d5e6ab123bfa. Content-Type: application/json; charset=UTF-8. Via: 1.1 localhost (Apache-HttpClient/4.5.5 (cache)). Content-Length: 1149. Host: host.docker.internal:8080. Connection: Keep-Alive. User-Agent: Atlassian HttpClient 2.1.0 / Bitbucket-7.6.3 (7006003) / Default. . {"eventKey":"repo:refs_changed","date":"2021-05-17T23:12:02+0000","actor":{"name":"fclausen","emailAddress":"friedrich.clausen@blackboard.com","id":1,"displayName":"Friedrich Clausen","active":true,"slug":"fclausen","type":"NORMAL","links":{"self":[{"href":"http://host.docker.internal:7990/users/fclausen"}]}},"repository":{"slug":"example","id":12,"name":"example","hierarchyId":"000a8aa7f174baf248ce","scmId":"git","state":"AVAILABLE","statusMessage":"Available","forkable":true,"project":{"key":"PRJ","id":42,"name":"PROJECT","public":false,"type":"NORMAL","links":{"self":[{"href":"http://host.docker.internal:7990/projects/PRJ"}]}},"public":false,"links":{"clone":[{"href":"http://host.docker.internal:7990/scm/prj/example.git","name":"http"},{"href":"ssh://git@host.docker.internal:7999/prj/example.git","name":"ssh"}],"self":[{"href":"http://host.docker.internal:7990/projects/PRJ/repos/example/browse"}]}},"changes":[{"ref":{"id":"refs/heads/master","displayId":"master","type":"BRANCH"},"refId":"refs/heads/master","fromHash":"a2b8922d6dccf623e17c7eecb25074c6c0 # T 127.0.0.1:63025 -> 127.0.0.1:8080 [AP] f569e9","toHash":"0c6ae17586daf40ae84cc8ed02c9ea5d50db78e1","type":"UPDATE"}]} ### T 127.0.0.1:8080 -> 127.0.0.1:63025 [AP] HTTP/1.1 200 OK. Date: Mon, 17 May 2021 23:12:03 GMT. X-Content-Type-Options: nosniff. Content-Length: 0. Server: Jetty(9.4.39.v20210325). . For convenience, the formatted payload above is: { "eventKey" : "repo:refs_changed" , "date" : "2021-05-17T23:12:02+0000" , "actor" : { "name" : "fclausen" , "emailAddress" : "friedrich.clausen@blackboard.com" , "id" : 1, "displayName" : "Friedrich Clausen" , "active" : true , "slug" : "fclausen" , "type" : "NORMAL" , "links" : { "self" : [ { "href" : "http: //host.docker.internal:7990/users/fclausen" } ] } }, "repository" : { "slug" : "example" , "id" : 12, "name" : "example" , "hierarchyId" : "000a8aa7f174baf248ce" , "scmId" : "git" , "state" : "AVAILABLE" , "statusMessage" : "Available" , "forkable" : true , "project" : { "key" : "PRJ" , "id" : 42, "name" : "PROJECT" , " public " : false , "type" : "NORMAL" , "links" : { "self" : [ { "href" : "http: //host.docker.internal:7990/projects/PRJ" } ] } }, " public " : false , "links" : { "clone" : [ { "href" : "http: //host.docker.internal:7990/scm/prj/example.git" , "name" : "http" }, { "href" : "ssh: //git@host.docker.internal:7999/prj/example.git" , "name" : "ssh" } ], "self" : [ { "href" : "http: //host.docker.internal:7990/projects/PRJ/repos/example/browse" } ] } }, "changes" : [ { "ref" : { "id" : "refs/heads/master" , "displayId" : "master" , "type" : "BRANCH" }, "refId" : "refs/heads/master" , "fromHash" : "a2b8922d6dccf623e17c7eecb25074c6c0f569e9" , "toHash" : "0c6ae17586daf40ae84cc8ed02c9ea5d50db78e1" , "type" : "UPDATE" } ] } Finally the FINEST logging shows (minus timestamps) Considering candidate job bitbucket-single-branch-pipeline bitbucket-single-branch-pipeline hasnt BitBucketTrigger set No SCM configuration was found! Now checking SCMSourceOwners/multiBranchProjects Considering candidate scmSourceOwner example Considering candidate scmSource com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource{id='e30d68a9-fddc-49ad-af73-53e1dbb3552c'} SCMSource is [BitbucketSCMSource] which is not supported SCM [example] doesn't match remote repo [prj/example]
          Hide
          tzach_solomon Tzach Solomon added a comment -

          Friedrich Clausen can you please add the web hook HEADERS and Body request from bitbucket?

          Show
          tzach_solomon Tzach Solomon added a comment - Friedrich Clausen can you please add the web hook HEADERS and Body request from bitbucket?

            People

            Assignee:
            tzach_solomon Tzach Solomon
            Reporter:
            ftclausen Friedrich Clausen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: