jenkinsci / bitbucket-branch-source-plugin

Bitbucket Branch Source Plugin
https://plugins.jenkins.io/cloudbees-bitbucket-branch-source
MIT License
216 stars 352 forks source link

ERROR: HTTP request error. Status: 403: Forbidden #315

Closed rnkhouse closed 4 years ago

rnkhouse commented 4 years ago

I am getting 403: Forbidden error when I set up a webhook. I already set up Bitbucket Endpoints in Jenkins config. Manage hooks are checked with valid credentials and Custom Jenkins Root URL is blank.

[Fri May 29 20:04:13 UTC 2020] Received com.cloudbees.jenkins.plugins.bitbucket.hooks.PushHookProcessor$1 UPDATED event from 
18.234.32.224 ⇒ https://smee.io/bitbucket-scmsource-hook/notify/ with timestamp Fri May 29 20:04:13 UTC 2020
Connecting to https://bitbucket.org with no credentials, anonymous access
ERROR: HTTP request error. Status: 403: Forbidden.
Access denied. You must have write or admin access.
com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRequestException: HTTP request error. Status: 403: Forbidden.
Access denied. You must have write or admin access.
at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getRequestAsInputStream(BitbucketCloudApiClient.java:911)
at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getRequest(BitbucketCloudApiClient.java:923)
at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getRepository(BitbucketCloudApiClient.java:388)
at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.getRepositoryType(BitbucketSCMSource.java:498)
at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.retrieve(BitbucketSCMSource.java:546)
at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:373)
at jenkins.scm.api.SCMSource.fetch(SCMSource.java:327)
at jenkins.branch.MultiBranchProject$SCMEventListenerImpl.processHeadUpdate(MultiBranchProject.java:1592)
at jenkins.branch.MultiBranchProject$SCMEventListenerImpl.onSCMHeadEvent(MultiBranchProject.java:1192)
at jenkins.scm.api.SCMHeadEvent$DispatcherImpl.fire(SCMHeadEvent.java:246)
at jenkins.scm.api.SCMHeadEvent$DispatcherImpl.fire(SCMHeadEvent.java:229)
at jenkins.scm.api.SCMEvent$Dispatcher.run(SCMEvent.java:505)
at jenkins.security.ImpersonatingScheduledExecutorService$1.run(ImpersonatingScheduledExecutorService.java:58)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

Your checklist for this issue

Pipeline logs:

[Fri May 29 19:57:43 UTC 2020] Starting branch indexing...
ERROR: [Fri May 29 19:57:43 UTC 2020] Could not update folder level actions from source 7f74d52b-12c8-4fec-9cd1-46fd598951b8
com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRequestException: HTTP request error. Status: 403: Forbidden.
Access denied. You must have write or admin access.
    at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getRequestAsInputStream(BitbucketCloudApiClient.java:911)
    at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getRequest(BitbucketCloudApiClient.java:923)
    at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getRepository(BitbucketCloudApiClient.java:388)
    at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.retrieveActions(BitbucketSCMSource.java:1038)
    at jenkins.scm.api.SCMSource.fetchActions(SCMSource.java:848)
    at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:600)
    at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:277)
    at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:164)
    at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1034)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:428)
deebloo commented 4 years ago

@rnkhouse "Connecting to https://bitbucket.org with no credentials, anonymous access" can you confirm your configuration or share a screenshot?

rnkhouse commented 4 years ago

@deebloo I have a multibranch pipeline project setup and configuration is in the below screenshot. When I set a periodical scan it's working fine only webhook is not working.

Screen Shot 2020-06-03 at 11 03 54 AM
deebloo commented 4 years ago

hmmmm not sure. Let me see if I can reproduce today sometime. Can you try creating a job that is of type Bitbucket Team/Project and see of you get the same problem?

rnkhouse commented 4 years ago

@deebloo Looks like in Bitbucket Team/Project, it's at least detecting the change from webhook but not triggering the build. Please see below logs:

[Wed Jun 03 16:00:50 UTC 2020] Received com.cloudbees.jenkins.plugins.bitbucket.hooks.PushHookProcessor$1 UPDATED event from 18.234.32.227 ⇒ https://smee.io/bitbucket-scmsource-hook/notify/ with timestamp Wed Jun 03 16:00:50 UTC 2020 Connecting to https://bitbucket.org using */** (bitbucket) Repository type: Git Looking up */ for branches Checking branch staging from /***** ‘Jenkinsfile’ found Met criteria Changes detected: staging (null → d7921764edb64513516723001e8bb388c79ac3a184) Did not schedule build for branch: staging

1 branches were processed (query completed) [Wed Jun 03 16:00:51 UTC 2020] com.cloudbees.jenkins.plugins.bitbucket.hooks.PushHookProcessor$1 UPDATED event from 18.234.32.227 ⇒ https://smee.io/bitbucket-scmsource-hook/notify/ with timestamp Wed Jun 03 16:00:50 UTC 2020 processed in 0.63 sec

deebloo commented 4 years ago

@rnkhouse if you downgrade the plugin to 2.7 do you still have the issue? I haven't messed with this plugin a ton with cloud only server

rnkhouse commented 4 years ago

@deebloo Strangely, it worked with version 2.7.0. So, it looks like this is an issue with 2.8.0

treaves commented 4 years ago

We're having the same issue. Why aren't binary releases available here? How is one to downgrade to 2.7.0?

treaves commented 4 years ago

I found 2.7.0, and experienced the same thing. I can pull and build, but not register webhooks.

rnkhouse commented 4 years ago

Is this fixed in version 2.9.2?

bitwiseman commented 4 years ago

@rnkhouse I doubt it we have not changed that code. This may have started happening because the plugin started requesting more hooks or the behavior of the server may have changed. @treaves seemed to indicate they had the same issue with 2.7.0. That points to a change in the server.

rnkhouse commented 4 years ago

Yeah, maybe. I checked in version 2.9.2 and it's working.

bitwiseman commented 4 years ago

Yay!