# The sonar don't register the code coverage values in python project

**URL:** <https://community.sonarsource.com/t/the-sonar-dont-register-the-code-coverage-values-in-python-project/108004>\
**Category:** SonarQube Server / Community Build\
**Tags:** pipeline, python, azuredevops-server, coverage\
**Created:** [January 25, 2024, 8:24pm UTC](https://community.sonarsource.com/t/the-sonar-dont-register-the-code-coverage-values-in-python-project/108004 "2024-01-25T20:24:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![JOAO\_PAULO\_MOREIRA1](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/joao_paulo_moreira1/32/53762_2.png) [@JOAO\_PAULO\_MOREIRA1](https://community.sonarsource.com/u/JOAO_PAULO_MOREIRA1)\
**Post date:** [January 25, 2024, 8:24pm UTC](https://community.sonarsource.com/t/the-sonar-dont-register-the-code-coverage-values-in-python-project/108004/1 "2024-01-25T20:24:25Z")

</div>

Hi, i am needing a help

My sonar don’t register the code coverage values, show only 0%, below is my the azure pipeline

```auto
jobs:
- job: 
  displayName: Sonar
  pool:
    name: default
 
  steps:
    - task: SonarQubePrepare@5
      inputs:
        SonarQube: SonarQube
        scannerMode: CLI
        configMode: manual
        cliProjectKey: ${{parameters.ProjectName}}
        extraProperties: |    
              sonar.verbose=true
              sonar.python.version=3.8
              sonar.sources=.
              sonar.tests=.
              sonar.test.inclusions=**/*.tests.*
              sonar.language=py
              sonar.python.coverage.reportPaths=$(System.DefaultWorkingDirectory)/**/cobertura-coverage.xml
              sonar.python.xunit.reportPath=$(System.DefaultWorkingDirectory)/$(EnginePath)/test.xml
              sonar.exclusions= **/*.sql,** /*.pks, **/*.pkb,** /* __init__.py,**/*main.py
              sonar.sourceEncoding=UTF-8

   - script: coverage run -m pytest
      displayName: 'Run unit tests'

    - script: coverage xml
      displayName: 'Run code coverage'

    - task: PublishCodeCoverageResults@1
      displayName: 'Publish CodeCoverage Results'
      inputs:
        codeCoverageTool: coverage
        summaryFileLocation: $(System.DefaultWorkingDirectory)/**/coverage.xml

    # Run Code Analysis task
    - task: SonarQubeAnalyze@5

    # Publish Quality Gate Result task
    - task: SonarQubePublish@5
      inputs:
        pollingTimeoutSec: '300'   

```

```auto
INFO
17:19:06.552 INFO: Sensor Python Sensor [python] (done) | time=30529ms

17:19:06.552 INFO: Sensor Cobertura Sensor for Python coverage [python]

17:19:06.552 DEBUG: Using pattern 'D:\TFS\Agents\TPRB1048-v3_1\_work\71\s/**/cobertura-coverage.xml' to find reports

17:19:06.669 WARN: No report was found for sonar.python.coverage.reportPaths using pattern D:\TFS\Agents\TPRB1048-v3_1\_work\71\s/**/cobertura-coverage.xml

17:19:06.669 INFO: Sensor Cobertura Sensor for Python coverage [python] (done) | time=117ms

17:19:06.670 INFO: Sensor PythonXUnitSensor [python]

17:19:06.670 DEBUG: Using pattern 'D:\TFS\Agents\TPRB1048-v3_1\_work\71\s/$(EnginePath)/test.xml' to find reports

17:19:06.785 WARN: No report was found for sonar.python.xunit.reportPath using pattern D:\TFS\Agents\TPRB1048-v3_1\_work\71\s/$(EnginePath)/test.xml

17:19:06.786 INFO: Sensor PythonXUnitSensor [python] (done) | time=115ms

17:19:06.786 INFO: Sensor JaCoCo XML Report Importer [jacoco]

17:19:06.787 INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml

17:19:06.789 INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer

17:19:06.789 INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=3ms

17:19:06.789 INFO: Sensor JavaScript inside YAML analysis [javascript]

17:19:06.800 INFO: No input files found for analysis

17:19:06.801 INFO: Hit the cache for 0 out of 0

17:19:06.802 INFO: Miss the cache for 0 out of 0

```

–

SonarQubeEnterprise LTS 9.9  
Python version is 3.8.8

---

<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:** [January 26, 2024, 4:46pm UTC](https://community.sonarsource.com/t/the-sonar-dont-register-the-code-coverage-values-in-python-project/108004/2 "2024-01-26T16:46:52Z")

</div>

Hi,

Welcome to the community!

Can you share the exact path to at least one of your coverage reports?

&nbsp;  
Thx,  
Ann

---

<div class="post-metadata">

**Author:** ![JOAO\_PAULO\_MOREIRA1](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/joao_paulo_moreira1/32/53762_2.png) [@JOAO\_PAULO\_MOREIRA1](https://community.sonarsource.com/u/JOAO_PAULO_MOREIRA1)\
**Post date:** [January 26, 2024, 8:06pm UTC](https://community.sonarsource.com/t/the-sonar-dont-register-the-code-coverage-values-in-python-project/108004/3 "2024-01-26T20:06:49Z")

</div>

Hi Ann,  
Confirm please if i understant your question

```auto
/usr/bin/dotnet /tfs/Agents/AgentV1/_work/_tasks/PublishCodeCoverageResults_2a7ebc54-c13e-490e-81a5-d7561ab7cd97/1.180.0/netcoreapp2.0/ReportGenerator.dll -reports:/tfs/Agents/AgentV1/_work/1490/s/**/coverage.xml -targetdir:/tfs/Agents/AgentV1/_work/_temp/cchtml -reporttypes:HtmlInline_AzurePipelines
2024-01-26T20:03:00: Arguments
2024-01-26T20:03:00: -reports:/tfs/Agents/AgentV1/_work/1490/s/**/coverage.xml
2024-01-26T20:03:00: -targetdir:/tfs/Agents/AgentV1/_work/_temp/cchtml
2024-01-26T20:03:00: -reporttypes:HtmlInline_AzurePipelines
2024-01-26T20:03:01: Writing report file '/tfs/Agents/AgentV1/_work/_temp/cchtml/index.html'
2024-01-26T20:03:01: Report generation took 0.2 seconds
Generated code coverage html report: /tfs/Agents/AgentV1/_work/_temp/cchtml
Reading code coverage summary from '/tfs/Agents/AgentV1/_work/1490/s/coverage.xml'
Async Command Start: Publish code coverage
Publishing coverage summary data to TFS server.
 Lines- 293 of 293 covered.
 Branches- 0 of 0 covered.
Modifying Cobertura Index file
Publishing code coverage files to TFS server.
Uploading 9 files
File upload succeed.
Published '/tfs/Agents/AgentV1/_work/_temp/cchtml' as artifact 'Code Coverage Report_574783'

```

---

<div class="post-metadata">

**Author:** ![JOAO\_PAULO\_MOREIRA1](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/joao_paulo_moreira1/32/53762_2.png) [@JOAO\_PAULO\_MOREIRA1](https://community.sonarsource.com/u/JOAO_PAULO_MOREIRA1)\
**Post date:** [January 26, 2024, 8:59pm UTC](https://community.sonarsource.com/t/the-sonar-dont-register-the-code-coverage-values-in-python-project/108004/4 "2024-01-26T20:59:08Z")

</div>

Hi Ann,  
I found the problem, was wrong the reportPaths

Before  
sonar.python.coverage.reportPaths=$(System.DefaultWorkingDirectory)/\*\*/cobertura-coverage.xml

After  
sonar.python.coverage.reportPaths=coverage.xml

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [February 2, 2024, 8:59pm UTC](https://community.sonarsource.com/t/the-sonar-dont-register-the-code-coverage-values-in-python-project/108004/5 "2024-02-02T20:59:11Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
