Github Actions shows sonar coverage as zero using mvn

  • Using the sonar cube action from here → https://github.com/SonarSource/sonarqube-scan-action which spins up a docker container and runs the sonar.

  • Version of sonarcube server = 8.6

  • SONAR Scanner = 4.7.0

  • Version of Java used by SONAR is Java 11

  • Github actions template workflow file

        if: "!contains(github.event.head_commit.message, 'maven-release-plugin')"
        name: Sonar Scan
        runs-on: [ self-hosted]
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
          SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
        steps:
         - uses: actions/checkout@v2
           with:
             ref: ${{github.event.pull_request.head.ref}}
             repository: ${{github.event.pull_request.head.repo.full_name}}
         - run: mvn package -Dmaven.test.skip=true -P my_profile -U -s settings.xml
         - name: SonarQube Scan - PR
           if: ${{ github.event_name == 'pull_request_target' }}
           uses: sonarsource/sonarqube-scan-action@master
           with:
             args: >
              -Dsonar.pullrequest.key=${{github.event.number}}
              -Dsonar.pullrequest.branch=PR-${{github.event.number}}
              -Dsonar.pullrequest.base=master
              -Dsonar.working.directory=/tmpDir/${{github.sha}}/sonar
         - name: SonarQube Scan - Push
           if: ${{ github.event_name == 'push' }}
           uses: sonarsource/sonarqube-scan-action@master
           with:
             args: >
                 -Dsonar.working.directory=/tmpDir/${{github.sha}}/sonar ```

Hi,

Welcome to the community!

Your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

8.6 → 8.9.7 → 9.3 (last step optional)

You may find the Upgrade Guide helpful. If you have questions about upgrading, feel free to open a new thread for that here.

Regarding your question, it’s not clear to me whether or not your mvn package command is producing a test report. Is it?

 
Ann