bitbucket-push-and-pull-request-plugin icon indicating copy to clipboard operation
bitbucket-push-and-pull-request-plugin copied to clipboard

Cannot get multibranch pipelines to trigger on push

Open mpschmitt opened this issue 1 year ago • 12 comments

I've been wrestling this for a bit now, so I thought I'd reach out for some extra help. I'm running Bitbucket 7.21 Server with Jenkins 2.414.3 and Bitbucket Push and Pull Request Plugin 3.0.0

My job is using multibranch pipeline.

Here's the current state. In my Jenkinsfile I have added:

properties([
  pipelineTriggers([
    [
      $class: 'BitBucketPPRTrigger',
      triggers : [
        [
          $class: 'BitBucketPPRRepositoryTriggerFilter',
          actionFilter: [
            $class: 'BitBucketPPRServerRepositoryPushActionFilter',
            triggerAlsoIfNothingChanged: true,
            triggerAlsoIfTagPush: false,
            allowedBranches: ""
          ]
        ]
      ]
    ]
  ])
])

pipeline {...etc.

When I push after making a change in my branch, I see that the event is received properly, but the build is not kicked off:

`Dec 06, 2023 7:49:58 AM INFO io.jenkins.plugins.bitbucketpushandpullrequest.receiver.BitBucketPPRHookReceiver doIndex
Received POST request over Bitbucket hook
Dec 06, 2023 7:49:58 AM INFO io.jenkins.plugins.bitbucketpushandpullrequest.processor.BitBucketPPRPayloadProcessorFactory createProcessor
Create BitBucketPPRRepositoryServerPayloadProcessor
Dec 06, 2023 7:49:58 AM INFO io.jenkins.plugins.bitbucketpushandpullrequest.action.BitBucketPPRServerRepositoryAction 
Received commit hook notification from server for destination branch: jenkins-prod-test1
Dec 06, 2023 7:49:58 AM INFO io.jenkins.plugins.bitbucketpushandpullrequest.action.BitBucketPPRServerRepositoryAction 
Received commit hook type from server: BRANCH`

The build doesn't start automatically. If I do a multibranch scan manually it picks up the change and the build starts.

I see that other folks have had issues with multibranch pipelines, but can anyone see a reason why this wouldn't work? Or any tips where else I might look for more clues?

mpschmitt avatar Dec 06 '23 13:12 mpschmitt

A bit more detail:

I do also have the older Bitbucket plugin installed, but I took the necessary workaround step to change the hook URL for this to be bitbucket-ppp-hook

The sending of the information over that webhook appears to be working fine, it's some issue with when it gets received on the Jenkins side and gets dropped for some reason.

mpschmitt avatar Dec 08 '23 21:12 mpschmitt

My URL looks like this on the bitbucket side for the webhook:

https://[my jenkins server]/bitbucket-ppp-hook/

mpschmitt avatar Dec 08 '23 21:12 mpschmitt

If I look at the Bitbucket Push and Pull request Hook log in the view of the branch job that should have run, I see: image

mpschmitt avatar Dec 08 '23 21:12 mpschmitt

Similarities with this issue? https://github.com/jenkinsci/bitbucket-push-and-pull-request-plugin/issues/99

mpschmitt avatar Dec 08 '23 21:12 mpschmitt

And this is how I've configured the URL image

mpschmitt avatar Dec 08 '23 21:12 mpschmitt

In my Multibranch Pipeline configuration I have these checked: image

mpschmitt avatar Dec 08 '23 21:12 mpschmitt

I realized that the manage hooks option is not selected for this Bitbucket endpoint. Should it be?

image

mpschmitt avatar Dec 08 '23 21:12 mpschmitt

I added some more logging to the logger and I can see that it's receiving the payload correctly:

Dec 12, 2023 12:21:26 PM INFO io.jenkins.plugins.bitbucketpushandpullrequest.receiver.BitBucketPPRHookReceiver doIndex
Received POST request over Bitbucket hook
Dec 12, 2023 12:21:26 PM FINEST io.jenkins.plugins.bitbucketpushandpullrequest.receiver.BitBucketPPRHookReceiver
the payload is: {"actor":{"name":"[REDACTED]","emailAddress":"[REDACTED]","id":"2553","displayName":"[REDACTED]","active":true,"slug":"[REDACTED]","type":"NORMAL","links":{"clone":[],"self":[{"href":"http://[REDACTED]"}]}},"repository":{"slug":"[REDACTED]","id":"125","name":"[REDACTED]"scmId":"git","state":"AVAILABLE","statusMessage":"Available","forkable":true,"project":{"key":"DEV","id":"103","name":"[REDACTED]","links":{"clone":[],"self":[{"href":"http://[REDACTED]"}]},"public":false,"type":"NORMAL"},"links":{"clone":[{"href":"ssh://git@[REDACTED].git","name":"ssh"},{"href":"http://[REDACTED].git","name":"http"}],"self":[{"href":"http://[REDACTED]"}]},"public":false},"changes":[{"ref":{"id":"refs/heads/jenkins-prod-test1","displayId":"jenkins-prod-test1","type":"BRANCH"},"refId":"refs/heads/jenkins-prod-test1","fromHash":"[REDACTED]","toHash":"[REDACTED]","type":"UPDATE"}]}
Dec 12, 2023 12:21:26 PM FINE io.jenkins.plugins.bitbucketpushandpullrequest.observer.BitBucketPPRObserverFactory
Add BitBucketPPRPushServerObserver for {}
Dec 12, 2023 12:21:26 PM INFO io.jenkins.plugins.bitbucketpushandpullrequest.action.BitBucketPPRServerRepositoryAction 
Received commit hook notification from server for destination branch: jenkins-prod-test1
Dec 12, 2023 12:21:26 PM INFO io.jenkins.plugins.bitbucketpushandpullrequest.action.BitBucketPPRServerRepositoryAction 
Received commit hook type from server: BRANCH

mpschmitt avatar Dec 12 '23 17:12 mpschmitt

One of the classes I've specified in my logger is io.jenkins.plugins.bitbucketpushandpullrequest.filter.repository.BitBucketPPRServerRepositoryPushActionFilter

But I'm not seeing any messages related to that one when I check the logger log. Does that mean the trigger is just not firing at all for some reason?

mpschmitt avatar Dec 12 '23 19:12 mpschmitt

Discovered this article and realized that as of Bitbucket 5.4, native build triggering webhooks are supported, so I no longer need this plugin:

https://docs.cloudbees.com/docs/cloudbees-ci-kb/latest/client-and-managed-controllers/how-to-trigger-multibranch-jobs-from-bitbucket-server#configuration-in-bitbucket-server

Got that working pretty quickly. We can probably close this ticket unless someone feels highly motivated to get this fixed.

mpschmitt avatar Dec 13 '23 00:12 mpschmitt

@mpschmitt thank you, Happy to read that you have found a solution!

I’m going to analyze the problem. I hope, I can replicate it, that is the hard part.

cdelmonte-zg avatar Dec 23 '23 08:12 cdelmonte-zg

Hi team, I have the same issue and can assist with troubleshooting if required. I'd prefer to use this plugin because I want access to the payload to do interesting things with the pipeline.

Having the exact same behaviour. When configured using multibranch pipeline, the jobs don't fire but when configured as a single pipeline job on the same Jenkins server, it all works fine.

Interestingly, when you "View Configuration" on the branch, it has the configuration for the Push Pull Request plugin (under build triggers) all properly configured but the jobs just never actually get fired.

I'm just using the default webhook configuration with the BitBucket plugin disabled however, I do have the BitBucket Branch Source plugin enabled which is required for BlueOcean so cannot disable if it's required to be.

michaelishri avatar Jul 02 '24 02:07 michaelishri

@michaelishri Hello! I was not able to replicate the issue. Did you check the option "Build with BitBucket Push and Pull Request Plugin"?

julioc-p avatar Sep 13 '24 13:09 julioc-p

This issue will be closed because of inactivity.

julioc-p avatar Sep 26 '24 08:09 julioc-p