jenkinsci / bitbucket-branch-source-plugin

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

"Can't find clone link for protocol HTTP" With Checkout over SSH #811

Closed rpaasche closed 3 months ago

rpaasche commented 4 months ago

Jenkins and plugins versions report

Environment ```text - BitBucket DC 8.18.0 - HTTP(S) SCM hosting is diabled ```

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

It's all running in Kubernetes.

Reproduction steps

  1. Disable HTTP(S) SCM Host in Bitbucket
  2. select "Checkout over SSH" in Jenkins
  3. Pipeline:

    pipeline {
    options {
        buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '30', numToKeepStr: '10'))
        disableConcurrentBuilds()
        skipDefaultCheckout(true)
    }
    
    stages {
        stage('Initialize') {
            steps {
                script {
                    try{
                        checkout scm
                    } catch (exc) {
                      def sw = new StringWriter()
                      def pw = new PrintWriter(sw)
                      exc.printStackTrace(pw)
                      echo sw.toString()
                    }
                }
            }
        }
    }
    }

Without skipDefaultCheckout it is failing silently with an empty working space.

Expected Results

Cloning without error

Actual Results

2024-02-16 10:47:59 | java.lang.IllegalStateException: Can't find clone link for protocol HTTP 2024-02-16 10:47:59 | at com.cloudbees.jenkins.plugins.bitbucket.BitbucketGitSCMBuilder.lambda$getCloneLink$1(BitbucketGitSCMBuilder.java:313) 2024-02-16 10:47:59 | at java.base/java.util.Optional.orElseThrow(Optional.java:403) 2024-02-16 10:47:59 | at com.cloudbees.jenkins.plugins.bitbucket.BitbucketGitSCMBuilder.getCloneLink(BitbucketGitSCMBuilder.java:313) 2024-02-16 10:47:59 | at com.cloudbees.jenkins.plugins.bitbucket.BitbucketGitSCMBuilder.withPrimaryRemote(BitbucketGitSCMBuilder.java:300) 2024-02-16 10:47:59 | at com.cloudbees.jenkins.plugins.bitbucket.BitbucketGitSCMBuilder.withBranchRemote(BitbucketGitSCMBuilder.java:293) 2024-02-16 10:47:59 | at com.cloudbees.jenkins.plugins.bitbucket.BitbucketGitSCMBuilder.withBitbucketRemote(BitbucketGitSCMBuilder.java:199) 2024-02-16 10:47:59 | at com.cloudbees.jenkins.plugins.bitbucket.BitbucketGitSCMBuilder.withCloneLinks(BitbucketGitSCMBuilder.java:130) 2024-02-16 10:47:59 | at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.build(BitbucketSCMSource.java:1033) 2024-02-16 10:47:59 | at org.jenkinsci.plugins.workflow.multibranch.SCMVar.getValue(SCMVar.java:111

Anything else?

Workaround is to enable "HTTP(S) SCM Host" in Bitbucket

Are you interested in contributing a fix?

No response

melorbany commented 4 months ago

@rpaasche Which version of bitbucket-branch-source-plugin plugin are you using?

rpaasche commented 4 months ago

Latest 874.v659a_b_70f5e69

MartinHelwig commented 4 months ago

Hello, I have the same problem while "Scan Multibranch Pipeline Now" with version 877.vb_b_d5243f6794 of the plugin. The bitbucket only allows ssh checkout.

java.lang.IllegalStateException: Can't find clone link for protocol HTTP at com.cloudbees.jenkins.plugins.bitbucket.BitbucketGitSCMBuilder.lambda$getCloneLink$1(BitbucketGitSCMBuilder.java:312) at java.base/java.util.Optional.orElseThrow(Optional.java:408) at com.cloudbees.jenkins.plugins.bitbucket.BitbucketGitSCMBuilder.getCloneLink(BitbucketGitSCMBuilder.java:312) at com.cloudbees.jenkins.plugins.bitbucket.BitbucketGitSCMBuilder.withPrimaryRemote(BitbucketGitSCMBuilder.java:299) at com.cloudbees.jenkins.plugins.bitbucket.BitbucketGitSCMBuilder.withBranchRemote(BitbucketGitSCMBuilder.java:292) at com.cloudbees.jenkins.plugins.bitbucket.BitbucketGitSCMBuilder.withBitbucketRemote(BitbucketGitSCMBuilder.java:198) 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)

Only switching back to version 866.vdea_7dcd3008e is working fine. Using Jenkins 2.426.3