I have a .gitlab-ci.yml that defines multiple jobs. I have a test job that runs on commits, and a security job that runs only on merge requests.
test-coverage:
stage: test
coverage: '/Line coverage: \d+(?:\.\d+)?%/'
before_script:
- dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools
script:
- dotnet test --collect "Code Coverage;Format=cobertura" --logger junit --results-directory results
- ./tools/reportgenerator -reports:results/*/*.cobertura.xml -reporttypes:"cobertura;textsummary" -targetdir:results
- head -n 17 results/Summary.txt
artifacts:
when: always
reports:
junit: results/TestResults.xml
coverage_report:
coverage_format: cobertura
path: results/Cobertura.xml
validate:
stage: validate
script: echo "valid"
only:
- merge_requests
The test job generates test and coverage reports to upload to gitlab, and this seems to be working as I can see them visualised when I go into the pipeline → jobs.
However, I can’t see the report widgets in merge requests. I’m not completely sure, but it looks like this is because it’s only looking for the reports in the latest pipeline, which is the merge request pipeline without the test job.
Is this right? And if so, is there a way around this without having to run a duplicate test job on the merge request pipeline?