Github Actions "Project was never analyzed" issue

While trying to use Github actions and SonarCloud i’ve been hitting an issue with the first analysis of a project. I cooked up a small example to isolate the issue.

The project and workflow live in where the workflow is defined like this:

name: Java CI
on: push

    runs-on: ubuntu-latest
    - uses: actions/checkout@v1
    - name: Set up JDK 1.8
      uses: actions/setup-java@v1
        java-version: 1.8
    - name: Build with Maven
      run: mvn -B package
    - name: Analyse with Sonar
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
      run: mvn -B sonar:sonar -Dsonar.organization=hbfernandes

I’ve created an organization is SonarCloud from my github account called “hbfernandes” which is completely empty. When the above workflow runs i get the following:

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin: (default-cli) on project my-app: Project was never analyzed. A regular analysis is required before a branch analysis. -> [Help 1]

Full execution here

If i run the same maven command locally i get a successful analysis posted so i’m guessing there is some property being filled by the the fact it’s running on Github actions. Is there a workaround for this, some property i can use perhaps?

I’ve tried using and to “master” but it made no difference.

Welcome to the community forum and thank you for providing a clear description!

Correct, we use the variables provided by Github to determine if we should run a pullrequest analysis or a regular branch analysis. I see that you are running the GitHub action in the context of a pullrequest. To run pullrequest analysis we have to be able to compare the changes to an already existing analysis of the target branch. That is the error you are seeing.

However there should not be any error anymore after you ran the scanner on the ‘master’ branch locally.

Setting the parameter to master should trigger a regular analysis of the master branch. Can you share the output of the command when you set that parameter?


Thank you for your reply!

I am confused when you say i’m running this on the context of a pull request. This is on master and the trigger was a push to master, there are no pull requests for this repo so how can it be ran in the context of a pull request?

I’ve added again the parameter you’ve asked, here is the full build output

If there is more information i can provide let me know.


Sorry for that, you are right.

Anyway when branch analysis is triggered, we already expect there to be an analysis present. Running in github actions will automatically set the and will thus always trigger branch analysis.

This should however not be the case, I created a ticket for that here where you can follow the progress.

Thanks for the feedback!

Thanks a lot @TomVanBraband! I’ll follow that ticket.

Hi @bjam,

I need a bit more information. Which branch are you trying to analyze? What do you see when you select Administration > Branches & Pull Requests, is the branch you are trying to analyze marked as the main branch?


Hi @TomVanBraband, I’ve deleted my message as I don’t think I’d setup my sonar project correctly.

1 Like