bitbucket-branch-source-plugin: Unable to create new multibranch pipeline project (Error while loading repositories from cache)
Your checklist for this issue
-
Jenkins version: 2.250.0
-
Plugin version: 2.8.0, 2.9.1
-
Bitbucket cloud
-
Bitbucket server and version: v6.10.0
Description
After upgrading to 2.8.0 (and now 2.9.1)
I’m trying to create a new multibranch pipeline job. I have already configured a Bitbucket Server Endpoint in the Jenkins System Configuration.
When configuring the branch source, after clicking on the “Add source” button and selecting “Bitbucket” I have the following problem:
I select the credentials as usual, and set the project name. Then, iteration of the repositories (to fill the dropdown) fails with the error message “Error while loading repositories from cache”.
This used to work previously (before updating to version 2.8.0 of this plugin).
Workaround:
I can create a copy of an existing job (which I configured before the update), then selecting a repository works as usual.
Additional info: After some searching on my own, it seems that the serverUrl
of the BitbucketSCMSource
somehow gets defaulted to https://bitbucket.org
(as seen in the new jobs config.xml
).
Logs show entries like this (sanitized):
Jul 30, 2020 2:42:51 PM FINE com.cloudbees.jenkins.plugins.bitbucket.api.credentials.BitbucketUsernamePasswordAuthenticator
Add host=https://api.bitbucket.org to authCache.
Jul 30, 2020 2:42:51 PM FINE com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient
Jenkins proxy: xxxxxxxxx.xxx/xx.xx.xx.xx:xxxx
Jul 30, 2020 2:42:51 PM FINE com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient
Using proxy authentication (user=xxxxxxxxxxxxxxxxxxx)
Jul 30, 2020 2:42:51 PM SEVERE com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource$DescriptorImpl doFillRepositoryItems
Error while loading repositories from cache
com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRequestException: HTTP request error. Status: 407: Proxy Authentication Required.
<snip html response>
at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getRequestAsInputStream(BitbucketCloudApiClient.java:918)
at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getRequest(BitbucketCloudApiClient.java:930)
at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.lambda$getRepositories$4(BitbucketCloudApiClient.java:774)
at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getRepositories(BitbucketCloudApiClient.java:790)
Caused: java.io.IOException: Error while loading repositories from cache
at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getRepositories(BitbucketCloudApiClient.java:793)
at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource$DescriptorImpl.doFillRepositoryItems(BitbucketSCMSource.java:1215)
at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:396)
at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:408)
at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:212)
at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:145)
at org.kohsuke.stapler.MetaClass$11.doDispatch(MetaClass.java:536)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.MetaClass$4.doDispatch(MetaClass.java:281)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.MetaClass$4.doDispatch(MetaClass.java:281)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.MetaClass$4.doDispatch(MetaClass.java:281)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:766)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:694)
at org.kohsuke.stapler.Stapler.service(Stapler.java:240)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:763)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1631)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)
at jenkins.telemetry.impl.UserLanguages$AcceptLanguageFilter.doFilter(UserLanguages.java:129)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
at jenkins.security.ResourceDomainFilter.doFilter(ResourceDomainFilter.java:76)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
at org.jenkinsci.plugins.ssegateway.Endpoint$SSEListenChannelFilter.doFilter(Endpoint.java:248)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
at io.jenkins.blueocean.ResourceCacheControl.doFilter(ResourceCacheControl.java:134)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
at io.jenkins.blueocean.auth.jwt.impl.JwtAuthenticationFilter.doFilter(JwtAuthenticationFilter.java:61)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
at org.jenkinsci.plugins.modernstatus.ModernStatusFilter.doFilter(ModernStatusFilter.java:52)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
at hudson.plugins.locale.LocaleFilter.doFilter(LocaleFilter.java:42)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:151)
at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:157)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:153)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:93)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:90)
at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:51)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
at jenkins.security.SuspiciousRequestFilter.doFilter(SuspiciousRequestFilter.java:36)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1618)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:549)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:578)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1610)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1369)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:489)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1580)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1284)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
at org.eclipse.jetty.server.Server.handle(Server.java:501)
at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:383)
at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:556)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:375)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:272)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:375)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938)
at java.lang.Thread.run(Thread.java:748)
I’m not sure why the plugin thinks this should be a Cloud Endpoint (as we have no configuration for those, just a single Server Endpoint), nor whether the (expected, at least for https://api.bitbucket.org
) proxy error is throwing wrenches into some endpoint detection logic.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 12
- Comments: 21 (4 by maintainers)
I confirm the bug. My setup is:
@hoffmale , your fix works fine
Enough to replace https://bitbucket.org to your own bitbucket server URL in config.xml and then do the reread Jenkins config from the Jenkins settings.
I have this problem too
Jenkins 2.253 Bitbucket Branch Source Plugin: 2.9.2 Bitbucket v7.1.3
When I try to create a new multibranch pipeline project, I have the following error:
Could not find: <project_key>
I got over this problem, adding the Bitbucket Cloud endpoint in Jenkins > Config
And, next when I try to create a new project, the repositories are returned correctly, when I select our Bitbucket Server.
Strangely, if I add two servers (prod / dev), without the Bitbucket Cloud server, the problem is also got over.
Same problem here, running Jenkins 2.249.2 and 2.9.4 with a single bitbucket server instance
@rbywater Thank you so much for the code.
@bitwiseman Now is it possible to quickly fix this and release a new version? It should hardly take an hour.
Same issue here. Setting up a new Jenkins Server with OnPremise Bitbucket server.
Used versions:
Initial setup:
Solution:
I have the same issue and went through the code and couldn’t find anything obvious as to why its stopped working - I can only assume it may be related to a Jenkins core change along the way as well?
I think the fix is to change the line in doFillRepositoryItems
serverUrl = StringUtils.defaultIfBlank(serverUrl, BitbucketCloudEndpoint.SERVER_URL);
to something likeserverUrl = StringUtils.defaultIfBlank(serverUrl, BitbucketEndpointConfiguration.get().getEndpointItems().size() > 0 ? BitbucketEndpointConfiguration.get().getEndpointItems().get(0) : BitbucketCloudEndpoint.SERVER_URL);
(That is if we don’t have a server URL then there’s either 0 or 1 entries, therefore try and see if there is 1 entry and use that, else fall back to using Cloud)
Note the above snippet is completely untested at the mo 😄
@bitwiseman this is the “Bitbucket Integration Plugin”. I set up the connection in the “Bitbucket Integration Plugin” section of the Jenkins config. And this is what works together with the “Bitbucket Branch Source Plugin” at last this is what Jenkins says. Apart from this…it is really annoying that all parties point to each other and the end user has to fiddle around with all this stuff to get it working. As a plugin developer you’re supposed to either deprecate the whole thing and say
sorry guys I don't care anymore, bye
or fix the damn issue. That’s why in Microsoft Windows there was a fix for Sim City so that the end user (us) doesn’t have to bother. This whole ecosystem is oozing with this shit and I think I should just drop Jenkins and Bitbucket altogether and use an integrated solution that just works. In fact, I just decided to do so now.Freshly created
config.xml
:Old multibranch pipeline job:
Most interesting are the following two snippets (commented): new:
old:
For comparison, the global settings look like this:
Manually exchanging the
<serverUrl>
in a job’sconfig.xml
works, as does copying an already existing job. I have no idea where thehttps://bitbucket.org
server URL comes from; my assumption is that this is the bitbucket cloud one?Adding a second (dummy) Bitbucket Server entry worked fine for me, as a workaround. Damyan
Hello,
have same issue. I don’t use bitbucket cloud and now configuring a job with only one server configured in Jenkins makes the plugin try to call “ghost cloud” account instead of using the only one declared in the server settings.
Adding two servers or one cloud and one on premise in the config, makes the “list box model” appearing in the Multibranch job source and you can then select which server to use and it’s fine.
This is my init groovy script and I had to explicitly remove the default “bitbucket cloud” instance having to remove all endpoints and adding the only one I need.