Code Coverage with Angular and DevOps

I’m using Sonarqube Community Edition Version 9.0 (build 45539)

Apologies if this has been covered previously but I seem to have tried everything from many different articles and pieces on this forum but nothing seems to work.

I am trying to update Sonarqube with code coverage information for an Angular application using DevOps pipelines.

I am using Angular 8 with karma-coverage-istanbul-reporter and can generate an Icov report locally. If i push this report to DevOps and reference it then the paths are absolute as of my local configuration so this doesn’t work.

If I try to generate the report via DevOps a report seem to be created but there are still issues with paths within the Icov file.

These are my sonar properties:

sonar.projectKey=client
sonar.projectName=Client
sonar.projectVersion=1.0.0
sonar.sources=.
sonar.tests=.
sonar.exclusions=**/*.spec.ts,**/*test.ts,**/*.js
sonar.test.inclusions=**/*.spec.ts,**/*test.ts
sonar.coverage.exclusions=**/*.js,src/main.ts,src/polyfills.ts,**/*environment*.ts,**/*module.ts
sonar.javascript.lcov.reportPaths=$(Build.SourcesDirectory)\Client\coverage\lcov.info

This is the log from DevOps:

INFO: Sensor TypeScript analysis [javascript] (done) | time=141821ms
INFO: Sensor JavaScript/TypeScript Coverage [javascript]
INFO: Analysing [C:\vsts-agent\_work\86\s\Client\coverage\sonarqube\lcov.info]
WARN: Could not resolve 109 file paths in [C:\vsts-agent\_work\86\s\Client\coverage\sonarqube\lcov.info]
WARN: First unresolved path: C:\vsts-agent\_work\86\s\client\src\polyfills.ts (Run in DEBUG mode to get full list of unresolved paths)
INFO: Sensor JavaScript/TypeScript Coverage [javascript] (done) | time=16ms

Any help appreciated.
Many thanks
Lee

Hi,

Welcome to the community!

As you’ve discovered, you’re going to need to generate your reports in the same directory analysis is running from.

That’s a matter of your devOps configuration & unfortunately this may not be the best venue for advice on that.

 
:woman_shrugging:
Ann