Error "Could not find a default branch to fall back on" with Bitbucket and JAVA

Template for a good new topic, formatted with Markdown:

  • ALM used : Bitbucket
  • CI system used : Bitbucket Cloud
  • Languages of the repository : JAVA
  • Error observed : Could not find a default branch to fall back on

Hello,

I’m using SonarCloud to analyze a JAVA/MAVEN project. The project is on Bitbucket and the SonarCloud analysis is launched from a Bibbucket pipeline.

In Bitbucket, my “main branch” is set to the “master” branch.
main_branch_bitbucket

The pipeline is launched by the following YML script:

image: maven:3-amazoncorretto-11
clone:
  depth: full
definitions:
  steps:
    - step: &verify-sonar
        name: Build and test
        caches:
          - maven
        script:
          
		  ...
		  
          - bash create-settings.sh	
          - mvn -s settings.xml -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey="pgsConfiguration"
        artifacts:
          - target/**
pipelines:
  default:
    - step: *verify-sonar

But the BitBucket pipeline gives me the following error:

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project faberConfiguration: Could not find a default branch to fall back on. → [Help 1]

This error occurs since I changed the “main branch” in the project.

How can this problem be corrected?

Regards

Hello Olivier and welcome to the Community!

To help you to resolve this issue, can you please let me know which kind of analysis is failing? Main Branch, Pull Request or Branch analysis? The problem can be indeed related to the change of the project main branch.

Thanks

Peter

Hello Peter,
I try to analyse the main branch.
Regards,

Hello Olivier,

I apologise for a long delay before getting back to you.

I see you changed the main branch in the BitBucket interface. Did you rename the main branch also on the SonarCloud side? You can do that:

Let me know if that helps

Peter

Hello Peter,
Thank you for your answer.
I had finally resolved my error by deleting the SonarCloud project and recreating it.
Regards,

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.