Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.IllegalStateException: Can't find clone link for protocol HTTP #866

Open
cbolson1 opened this issue Jul 29, 2024 · 14 comments
Open

Comments

@cbolson1
Copy link

Jenkins and plugins versions report

Environment
bitbucket branch source plugin version = 888.v8e6d479a_1730

What Operating System are you using (both controller, and any agents involved in the problem)?

Oracle Linux

Reproduction steps

  1. install plugin version 871.v28d74e8b_4226
  2. Configure plugin to use Personal Access Token to read list of projects in Bitbucket
  3. Configure plugin to use Access Key to read specific Bitbucket repository
  4. Configure the plugin to use "checkout over SSH"

Expected Results

Check out the code from the specified repo

Actual Results

Looking up Wainwright/sidecar for branches
Checking branch master from Wainwright/sidecar
      ‘jenkins/sidecar.groovy’ found
    Met criteria
ERROR: [Mon Jul 29 15:05:11 GMT 2024] Could not fetch branches from source 354743ac-03b3-4fe9-aeca-236e377ad636
[Mon Jul 29 15:05:11 GMT 2024] Finished branch indexing. Indexing took 4.5 sec
FATAL: Failed to recompute children of Sidecar
java.lang.IllegalStateException: Can't find clone link for protocol HTTP
	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketGitSCMBuilder.lambda$getCloneLink$1(BitbucketGitSCMBuilder.java:313)
	at java.base/java.util.Optional.orElseThrow(Optional.java:403)
	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketGitSCMBuilder.getCloneLink(BitbucketGitSCMBuilder.java:313)
	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketGitSCMBuilder.withPrimaryRemote(BitbucketGitSCMBuilder.java:300)
	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketGitSCMBuilder.withBranchRemote(BitbucketGitSCMBuilder.java:293)
	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketGitSCMBuilder.withBitbucketRemote(BitbucketGitSCMBuilder.java:199)
	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketGitSCMBuilder.withCloneLinks(BitbucketGitSCMBuilder.java:130)
	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.build(BitbucketSCMSource.java:1034)
	at jenkins.scm.api.SCMSource.build(SCMSource.java:934)
	at jenkins.branch.MultiBranchProject.newBranch(MultiBranchProject.java:556)
	at jenkins.branch.MultiBranchProject$SCMHeadObserverImpl.observe(MultiBranchProject.java:2009)
	at jenkins.scm.api.trait.SCMSourceRequest.process(SCMSourceRequest.java:357)
	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.retrieveBranches(BitbucketSCMSource.java:793)
	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.retrieve(BitbucketSCMSource.java:633)
	at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:372)
	at jenkins.scm.api.SCMSource.fetch(SCMSource.java:282)
	at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:654)
	at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:269)
	at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:167)
	at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1057)
	at hudson.model.ResourceController.execute(ResourceController.java:101)
	at hudson.model.Executor.run(Executor.java:442)
Finished: FAILURE

Anything else?

This appears to be directly related to #804 . However, I tried the latest plugin version (888.v8e6d479a_1730), and that still shows this problem. Therefore I'm tempted to believe that #804 is not solved.

Are you interested in contributing a fix?

No

@cbolson1 cbolson1 added the bug label Jul 29, 2024
@rpaasche
Copy link

rpaasche commented Aug 5, 2024

Had the same issue, could be fixed by run "Scan Organization Folder" manualy. The most recent version 888.v8e6d479a_1730
is working just fine.

@cbolson1
Copy link
Author

cbolson1 commented Aug 5, 2024

I just have a single multibranch pipeline job setup; I don't have an organization folder configured here. Therefore, I don't think I can do what you are suggesting.

@cbolson1
Copy link
Author

cbolson1 commented Aug 5, 2024

One potentially important distinction here, I'm using the "checkout over SSH" feature in my job configuration.

@rpaasche
Copy link

rpaasche commented Aug 5, 2024

I just have a single multibranch pipeline job setup; I don't have an organization folder configured here. Therefore, I don't think I can do what you are suggesting.

In this case, it would be "Scan Multibranch Pipeline". Navigate to your job and it should be on the left side.

One potentially important distinction here, I'm using the "checkout over SSH" feature in my job configuration.

I do the same.

@cbolson1
Copy link
Author

cbolson1 commented Aug 5, 2024

Navigate to your job and it should be on the left side.

Yep. I did that. I still get the error message I posted in this issue.

@davehewitt
Copy link

davehewitt commented Oct 2, 2024

Hi, I am experiencing this issue with the latest version of the plugin, 888.v8e6d479a_1730 . I have been forced to keep this plugin downgraded due to this issue. Version 866.vdea_7dcd3008e is the last known working one for me.

@nfalco79
Copy link
Member

Do you have a Bitbucket server instance installed in the local NET? I do not know how DataCenter or Cloud instances can expose HTTP protocol instead of HTTPS.
We are using cloud so other instance kinds I do not know how configurations/features differ by the cloud type.

@cbolson1
Copy link
Author

@nfalco79 was 5b9b36e an attempt to fix this issue?

@nfalco79
Copy link
Member

No it was done to fix a regression where clone links (regardless the protocol) was not set anymore in commit 6e501b9

Regression was introduced after 888.v8e6d479a_1730 so I think does not resolve this issue, maybe could. If you have a chance to test latest version a report a feedback it would be great.

@SunMar
Copy link

SunMar commented Nov 21, 2024

Also ran into this issue today, was using the latest release, reverting to 866.vdea_7dcd3008e solved the issue.

@nfalco79 If you have some steps for me on how I can build the plugin from source I don't mind doing a little bit of debugging and see if I can find the issue. I'm not a Java developer however, so I'm not familiar with the ecosystem and things like Maven, so would need a step by step what commands to run to end up with a package that I can directly upload in my Jenkins. But I have a test Jenkins running on my machine where I could quickly iterate with debugging.

@SunMar
Copy link

SunMar commented Nov 25, 2024

@nfalco79 Managed to figure out how to build the package and did some debugging. The regression comes from commit ad359b3.

Here credentialsId is now passed as null:

return new BitbucketGitSCMBuilder(this, head, revision, null)

This affects the withCredentials() call in BitbucketGitSCMBuilder:

public BitbucketGitSCMBuilder withCredentials(String credentialsId, BitbucketRepositoryProtocol protocol) {
if (StringUtils.isNotBlank(credentialsId)) {
StandardCredentials credentials = BitbucketCredentials.lookupCredentials(
scmSource.getServerUrl(),
scmSource.getOwner(),
DescriptorImpl.SAME.equals(scmSource.getCheckoutCredentialsId()) ? credentialsId : scmSource.getCheckoutCredentialsId(),
StandardCredentials.class
);
if (protocol == null) {
protocol = credentials instanceof SSHUserPrivateKey
? BitbucketRepositoryProtocol.SSH
: BitbucketRepositoryProtocol.HTTP;
}
} else if (protocol == null) {
// If we set credentials to empty reset the type to HTTP.
// To set the build to use empty SSH credentials, call withProtocol after setting credentials
protocol = BitbucketRepositoryProtocol.HTTP;
}
this.protocol = protocol;
return withCredentials(credentialsId);

If credentialsId is set, it checks scmSource.getCheckoutCredentialsId() and if that is set, it switches to those credentials including the applicable protocol. If you are using SSHCheckoutTrait then getCheckoutCredentialsId() will return the SSH credentials id set in the trait and overrides the HTTP access token credentials.
Because credentialsId is now null, it never checks for the SSH credentials and defaults to using HTTP, which fails because our Bitbucket server does not allow HTTP checkouts.

If I simply add back the credentialsId parameter so it is not null anymore, it works again (even though it doesn't use those credentials).

Hopefully this helps. Also I tested with the current master version and there unfortunately this is still broken.

@nfalco79
Copy link
Member

nfalco79 commented Nov 25, 2024

Thanks to dig into the issue. If so this will be resolved by PR #867 but unfortunately it is blocked by jenkinsci/git-plugin#1649

@SunMar
Copy link

SunMar commented Nov 25, 2024

@nfalco79 thanks! I notice though that jenkinsci/git-plugin#1649 is already merged, did you maybe mean jenkinsci/git-plugin#1687 ? I see that PR is referenced there and still open.

@nfalco79
Copy link
Member

My fault, i mean this one
jenkinsci/git-plugin#1687
because 1649 has been reverted

@nfalco79 nfalco79 removed the bug label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants