Github action: Could not find a default branch to fall back on

I am getting error “Could not find a default branch to fall back on” when i try to run sonarqube command through github actions. Project doesn’t exist on sonarcloud.
If i manually create project, everything gonna work fine.
Any advice here?

ALM: Github
CI system used: Github Actions
Scanner command used: ./gradlew project-name:sonarqube -Dsonar.login=hidden
Languages of the repository: Java
Error observed: Could not find a default branch to fall back on


Welcome to the community!

Do any of these help?



Thanks for the answer. Unfortunatelly, no.
I am trying to create my projects automatically. My repo is multi-project, contain many microservices applications. It’s java, and we use gradle to build it.
Part of build.gradle.kts file:

sonarqube {
    properties {
        property("", "")
        property("sonar.organization", "testing-sonarcloud")
        property("sonar.projectKey", "${}")
        property("sonar.sources", "src/main/")
        property("sonar.tests", "src/test/")
        property("sonar.coverage.jacoco.xmlReportPaths", "build/reports/test/jacocoTestReport.xml")

Part of CI/CD process hosted on github:

        - name: Push sonarqube for ${{ matrix.subdir }} app
          if: github.ref == 'refs/heads/main' && github.event_name == 'push'
          id: push-sonar-cloud
          run: |
            gradle ${{ env.folder }}:${{ env.project }}:sonarqube -Dsonar.login=${{ secrets.SONAR_TOKEN }}
            GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
            SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

In case when project doesn’t exist on SonarCloud pipeline will fail with message:
Could not find a default branch to fall back on
If we manually create project on SonarCloud pipeline will finish without any error.

Is this even possible?

Any advice here?
Maybe i am doing something wrong?

Hi @devops-guru

Could you please give the logs produced by the Scanner during its execution, in debug mode?
To enable debug, you can add the option --debug in the gradle ...:sonarqube command line.


Hello @Claire_Villard

I am sending you part of log file. File is too large. Let me know if you need complete file. Thanks a lot!

sonarqube-devops-debug.log (26.4 KB)

I am bit confused here. When i enable --debug as part of gradle command the error is:

Unable to load component class org.sonar.scanner.scan.filesystem.InputComponentStore

When i remove --debug error is:

* What went wrong:

Execution failed for task ':notification:notification-gql-model:sonarqube'.

> Could not find a default branch to fall back on.


Hi @devops-guru

Sadly, today we do not support the automatic creation of projects from GitHub Actions. As you noticed, you have to import them on SonarCloud from your DevOps platform first (documentation). It will also create them bound to the DevOps platform, enabling for example the pull/merge request decoration feature.

The error is misleading, I’ll open an internal ticket to make it easier to understand.

We understand that for a large organization, importing all the projects can be a cumbersome operation. May I suggest you add your vote to this card? It is a candidate for our development roadmap, and having votes from users helps us prioritize the future features.

1 Like