“main” branch has not been analyzed yet and you have multiple branches already

  • ALM used (GitHub)
  • CI system used (Github Action)
  • Scanner command used when applicable (./gradlew build sonar --info)
  • Languages of the repository (Kotlin)
  • Steps to reproduce
    • Run github action using default gradle template

Hi All,
I need help to fix the issue in my main branch, it didn’t show the analysis.


Have you actually analyzed your main branch yet?

I see that you’ve analyzed develop, and I suspect that’s where most of the work happens; what you’d like to be treated as ‘main’.

To make that work, I believe you’ll need to:

  • dump your existing develop branch. You’ll loose your history, but since this is treated as a Short-lived branch, you’re losing functionality and you want to do this anyway
  • analyze develop and override the branch name in analysis to main/masterso it's taken as themain` branch. It’ll come in as “master”, rather than develop, but then you’ll
  • go to the project’s list of branches (shown in your screenshot) and use the 3-dots menu to ‘Rename Branch’ to develop


Hi Ann thanks for the support, I already do what you instructed but still no summary from my main branch. Here is what I am doing:

  • Delete develop branch (also in github)
  • Push New Code to main branch

Here is the CI Code:

name: SonarCloud Checking

      - main
    types: [ opened, synchronize, reopened ]
    name: Build and analyze
    runs-on: ubuntu-latest
      - uses: actions/checkout@v3
          fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis
      - name: Set up JDK
        uses: actions/setup-java@v3
          distribution: 'adopt'
          java-version: '11'
      - name: Cache SonarCloud packages
        uses: actions/cache@v3
          path: ~/.sonar/cache
          key: ${{ runner.os }}-sonar
          restore-keys: ${{ runner.os }}-sonar
      - name: Cache Gradle packages
        uses: actions/cache@v3
          path: ~/.gradle/caches
          key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
          restore-keys: ${{ runner.os }}-gradle
      - name: Build and analyze
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        run: ./gradlew build sonar --info

What am I missing here?


Can you share the analysis log?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.


Here is the analysis log

how to fix the error?

I already define the project properties and project org in the gradle


The anlaysis log would be everything (inclusive) from the analysis command through that error. But the error is pretty plain. One or more of the following is missing/bad:

  • sonar.projectKey analysis property
  • sonar.organization analysis property
  • SONAR_TOKEN env var

Your pipeline shows you setting the last one. How about the first two? Where are they set?


I already set up using the guideline but still didn’t get the main branch analysis, but when I set Pull Request the analysis works


What’s different between main branch and PR analysis?