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

**URL:** <https://community.sonarsource.com/t/github-action-could-not-find-a-default-branch-to-fall-back-on/70817>\
**Category:** SonarQube Cloud\
**Tags:** sonarqube\
**Created:** [September 1, 2022, 12:08pm UTC](https://community.sonarsource.com/t/github-action-could-not-find-a-default-branch-to-fall-back-on/70817 "2022-09-01T12:08:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![devops-guru](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@devops-guru](https://community.sonarsource.com/u/devops-guru)\
**Post date:** [September 1, 2022, 12:08pm UTC](https://community.sonarsource.com/t/github-action-could-not-find-a-default-branch-to-fall-back-on/70817/1 "2022-09-01T12:08:19Z")

</div>

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?  
Thanks

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

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [September 1, 2022, 6:19pm UTC](https://community.sonarsource.com/t/github-action-could-not-find-a-default-branch-to-fall-back-on/70817/2 "2022-09-01T18:19:55Z")

</div>

Hi,

Welcome to the community!

Do any of these help?

> [@Really confusing error (Could not find a default branch to fall back on): call for improvement](https://community.sonarsource.com/t/really-confusing-error-could-not-find-a-default-branch-to-fall-back-on-call-for-improvement/40586):
>
> Hi there, trying to integrate SonarCloud with Aure DevOps via yaml pipelines. And getting this “nice” error for step “SonarCloudAnalyze”: Could not find a default branch to fall back on. Yesterday I spend several hours trying to fix. You know, what was the issue? I had a project key: Xxx\_xxx\_xxx but in the step in the parameter I have entered xxx\_xxx\_xxx. Where was the difference? in the casing! What was the error? See above. Log? 2021-03-23T18:24:17.0078206Z INFO: Load project branches …

> [@Could not find a default branch to fall back on](https://community.sonarsource.com/t/could-not-find-a-default-branch-to-fall-back-on/25095/9):
>
> I tried deleting the project in SonarCloud and tried running the action again. I still get “Could not find a default branch to fall back on.” I can’t see anything special about my repository. I have a branch protection rule preventing pushes to the release branch, but that shouldn’t be relevant here since my Main branch is “main” and the current branch I’m running on is “main”. If I create it manually without “onboarding” I’m able to get it to work. However this sets it up with a “master” def…

> [@"Could not find a default branch to fall back on" GitLab Error](https://community.sonarsource.com/t/could-not-find-a-default-branch-to-fall-back-on-gitlab-error/56715):
>
> Hi Im having a same issue. My environment is: gitlab.com sonarcloud.io project in Java Build in gradle I configured the build.gradle like the first analisys with the tutorial in sonarcloud page, but i still have a exception. Blockquote org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedTh…

> [@Help with following error... "Could not find a default branch to fall back on."](https://community.sonarsource.com/t/help-with-following-error-could-not-find-a-default-branch-to-fall-back-on/25731/8):
>
> Let me quickly try that. I was told that the project would be automatically created. Oh well.

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![devops-guru](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@devops-guru](https://community.sonarsource.com/u/devops-guru)\
**Post date:** [September 2, 2022, 8:32am UTC](https://community.sonarsource.com/t/github-action-could-not-find-a-default-branch-to-fall-back-on/70817/3 "2022-09-02T08:32:45Z")

</div>

Hello,

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:

```auto
sonarqube {
    properties {
        property("sonar.host.url", "http://sonarcloud.io")
        property("sonar.organization", "testing-sonarcloud")
        property("sonar.projectKey", "${project.name}")
        property("sonar.sources", "src/main/")
        property("sonar.tests", "src/test/")
        property("sonar.coverage.jacoco.xmlReportPaths", "build/reports/test/jacocoTestReport.xml")
        property("sonar.core.codeCoveragePlugin","jacoco")
    }
}

```

Part of CI/CD process hosted on github:

```auto
        - 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 }}
          env:
            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?  
Thanks

---

<div class="post-metadata">

**Author:** ![devops-guru](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@devops-guru](https://community.sonarsource.com/u/devops-guru)\
**Post date:** [September 4, 2022, 1:54pm UTC](https://community.sonarsource.com/t/github-action-could-not-find-a-default-branch-to-fall-back-on/70817/6 "2022-09-04T13:54:17Z")

</div>

Any advice here?  
Maybe i am doing something wrong?  
Thanks

---

<div class="post-metadata">

**Author:** ![Claire\_Villard](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/claire_villard/32/27065_2.png) [@Claire\_Villard](https://community.sonarsource.com/u/Claire_Villard)\
**Post date:** [September 9, 2022, 9:32am UTC](https://community.sonarsource.com/t/github-action-could-not-find-a-default-branch-to-fall-back-on/70817/8 "2022-09-09T09:32:58Z")

</div>

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.

Thanks,  
Claire

---

<div class="post-metadata">

**Author:** ![devops-guru](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@devops-guru](https://community.sonarsource.com/u/devops-guru)\
**Post date:** [September 9, 2022, 11:11am UTC](https://community.sonarsource.com/t/github-action-could-not-find-a-default-branch-to-fall-back-on/70817/11 "2022-09-09T11:11:33Z")

</div>

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](https://community.sonarsource.com/uploads/short-url/wEKZjqym2Ifu7VQaUU6cY9ioT3v.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:

```auto
* What went wrong:

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

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

```

Thanks.

---

<div class="post-metadata">

**Author:** ![Claire\_Villard](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/claire_villard/32/27065_2.png) [@Claire\_Villard](https://community.sonarsource.com/u/Claire_Villard)\
**Post date:** [September 12, 2022, 6:50am UTC](https://community.sonarsource.com/t/github-action-could-not-find-a-default-branch-to-fall-back-on/70817/15 "2022-09-12T06:50:23Z")

</div>

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](https://docs.sonarcloud.io/getting-started/overview/)). It will also create them bound to the DevOps platform, enabling for example the [pull/merge request decoration](https://docs.sonarcloud.io/improving/pull-request-analysis/#pull-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](https://portal.productboard.com/sonarsource/1-sonarcloud/c/51-automatic-provisioning-of-bound-projects)? It is a candidate for our development roadmap, and having votes from users helps us prioritize the future features.
