SonarQube report with mixed C# and Python project not showing any python results

SonarQube: Enterprise Edition Version 9.9
Deployed with Docker and integrated to GitLab pipeline.

I have a dotnet project with the following structure.

The dotnet code is tested with nunit and the python part with pytest.
I created a pipeline for sonarqube in gitlab and I run a yaml script like this:

 - cd MyProject
 - dotnet sonarscanner begin /k:"PROJECT" /d:sonar.login="${SONAR_TOKEN}" /d:"${SONAR_HOST_URL}" /d:sonar.cs.vscoveragexml.reportsPaths="./coverage.xml" /d:sonar.python.version=3.9 /d:sonar.python.coverage.reportPaths="./python-coverage.xml"
 - chmod +x ./python-lib/  (Copies during dotnet build and publish python content to MyProject/Main/assets/python..)
 - dotnet restore
 - dotnet build -c Release --no-incremental --no-restore
 - dotnet-coverage collect 'dotnet test' -f xml  -o './coverage.xml'
 - cd ./python-lib
 - python -m pytest --cov=repositories --cov=maps --cov-report=xml:../python-coverage.xml --junitxml=../pytest-results.xml
 - cd ..
 - dotnet sonarscanner end /d:sonar.login="${SONAR_TOKEN}"

but no results of the static code analysis or coverage for the python-lib is shown in the sonarqube results. What I miss to configure?

Hey there.

Take a look at the Analyzing languages other than C# and VB section of the Scanner for .NET documentation.

Thank you,

I included:

        <Content Include="../python-lib/**/*.py" />

to the MyProject.csproj and this solves my problem.

Now also Python and C# is analyzed and included to the SonarScanner results.

1 Like

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