Code Coverage statistics are not displayed

Problem to solve

Hello everyone. There was such a problem. Code Coverage is not displayed in Analyze->Analytics Repositories, writes: “No code coverage data. Code coverage results are not yet available. Try again later.”. In pipelines, the Jobs section also does not reflect coverage as a percentage. I checked all the settings several times, checked everything with the documentation, everything should work. At the same time, you can download the artifact and open it, and it shows the percentage of coverage there, but it does not show it in GitLab itself. The GitLab server is deployed on a local machine and forwarded to the port. There is access to it from the Internet. Tell me, how can I solve the problem with the show?

Configuration

.gitlab-ci.yml:

Blockquote

stages:          
  #- build
  - test

#build-job:     
  #stage: build
  #script:
    #- echo "Compiling the code..."
    #- docker build -t test-image .
    #- docker ps -a
    #- echo "Compile complete."

#unit-test-job:   
  #stage: test 
  #script:
    #- echo "Running unit tests..."
    #- docker run -d --name test-container --rm test-image /bin/bash -c "dotnet test /app/tests/TestProject1.csproj --collect:'XPlat Code Coverage' --results-directory /app/tests/cobertura && tail -f /dev/null"
    #- docker ps -a
    #- docker cp test-container:/app/tests/cobertura/*/coverage.cobertura.xml ./coverage.cobertura.xml
    #- docker stop test-container
    #- echo "Unit tests complete."

coverage-code-job:   
  stage: test
  image: mcr.microsoft.com/dotnet/sdk:8.0    
  script:
    - echo "Running coverage code..."
    - dotnet test ./tests/TestProject1.csproj --collect:'XPlat Code Coverage'
    - echo "Code coverage complete."
  artifacts:
    paths:
      - /builds/pkoptev/test-project/tests/TestResults/*/coverage.cobertura.xml
    reports:
      coverage_report:
        coverage_format: cobertura
        path: /builds/pkoptev/test-project/tests/TestResults/*/coverage.cobertura.xml
  coverage: '/\d+\.\d+%/'

Versions

  • GitLab: v17.4.2
  • GitLab Runner: 17.5.0