Sonar Quality Gate including code coverage with SCM binding

  • ALM used - GitHub
  • CI system used - GitHub Actions
  • Scanner command used when applicable
      - name: SonarCloud Scan
        uses: sonarsource/sonarqube-scan-action@v5
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_CI }}
        with:
          args: >
            -Dsonar.projectKey=myorg_myprojectkey
            -Dsonar.organization=myorg
  • Languages of the repository - Typescript
  • Error observed
ERROR Could not find a default branch for project with key 'myorg_myprojectkey'. Make sure project exists.

I have configured a project via SCM binding as follows:

  • Analyze new project
  • Select from list of projects pulled from SCM
  • Set new code definition to “previous version”

When I use sonarsource/sonarqube-scan-action in my GitHub workflow to send results to SonarCloud, I get the message:
ERROR Could not find a default branch for project with key 'myorg_myprojectkey'. Make sure project exists.

If I recreate the project in Sonar manually while changing nothing else, the action works with no issues.

After importing via SCM binding, I’ve disabled automatic analysis based on these docs that state that CI-based analysis is not compatible with automatic analysis: Integrated CIs | SonarQube Cloud Documentation, yet I continue to receive this message.

I’d like to be able to import the project via SCM binding, but need to trigger analysis in CI only after the coverage report is generated. When configured via SCM binding, I see that Sonar is commenting on the PR, but isn’t picking up any coverage. Is it not possible to configure coverage reporting with a project imported via SCM binding?

Hi,

Welcome to the community!

Could you explain what you mean by this? What are the steps you take to “recreate… manually”?

Also could you post the full analysis log where you see the failure?

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.

 
Thx,
Ann