-
Type:
Improvement
-
Resolution: Fixed
-
Priority:
Minor
-
Component/s: bitbucket-branch-source-plugin
Problem
BitbucketSCMSource does not appear as an option in the "Modern SCM" retriever dropdown when configuring Global Shared Pipeline Libraries in Jenkins (Manage Jenkins → System → Global Trusted Pipeline Libraries → Retrieval method: Modern SCM).
Only "GitHub" and "Git" appear as options. Users are forced to use the legacy "Git" SCM source for Bitbucket shared libraries, which means:
- Credentials must be configured separately (not inherited from the Bitbucket SCM source)
- OAuth credentials don't work (GIT_ASKPASS is set with consumer key:secret which Bitbucket rejects for git HTTPS auth)
- No automatic server URL resolution from the endpoint configuration
Root Cause
The pipeline-groovy-lib-plugin's SCMSourceRetriever.DescriptorImpl.getSCMDescriptors() only lists SCM sources that override either:
- SCMSource.retrieve(String, TaskListener)Â (deprecated)
- SCMSource.retrieve(String, TaskListener, Item)Â (since scm-api 2.6.0)
GitHubSCMSource implements retrieve(String, TaskListener, Item) and appears in the dropdown. BitbucketSCMSource does not override either method, so it is excluded.
Additionally, when the override is added, two pre-existing issues in the DescriptorImpl form handlers are exposed because BitbucketSCMSource was never previously rendered in the Global System config context (where @AncestorInPath SCMSourceOwner is null):
- doFillCredentialsIdItems passes null context to BitbucketCredentialsUtils.listCredentials(@NonNull Item, ...) → NPE
- doCheckServerUrl reports "Unregistered Server:" when the value is blank during form initialization
Fix
- Implement retrieve(String thingName, TaskListener listener, Item context) in BitbucketSCMSource — resolves thingName as branch → tag → commit hash (in that order), returns null if nothing matches
- Handle null SCMSourceOwner in doFillCredentialsIdItems by falling back to Jenkins.get() (the ItemGroup<?> overload)
- Return FormValidation.ok() in doCheckServerUrl when value is blank
Affected Versions
All versions of cloudbees-bitbucket-branch-source (tested on 937.3.4)
Environment
- Jenkins 2.555.3
- pipeline-groovy-lib 730.v12c800a_bda_b_4
- scm-api 696.698.v507a_27a_46524
Steps to Reproduce
- Install cloudbees-bitbucket-branch-source plugin
- Navigate to Manage Jenkins → System → Global Trusted Pipeline Libraries
- Add a library, set Retrieval method to "Modern SCM"
- Observe that "Bitbucket" does not appear in the Source Code Management dropdown
Expected Behaviour
"Bitbucket" appears as an option alongside "GitHub" in the Modern SCM retriever, allowing shared libraries to be loaded from Bitbucket repositories using the same credential/endpoint configuration as multibranch pipelines.