Sonar Issue with Coverage Validation of Apex Classes(Salesforce) in Azure Pipeline

Template for a good new topic, formatted with Markdown:

  • ALM used - Azure DevOps

  • CI system used - Azure DevOps

  • Languages of the repository - English

  • Error observed ‘‘‘ ##[error]14:19:29.155 ERROR [baseline-browser-mapping] The data in this module is over two months old. To ensure accurate Baseline data, please update: `npm i baseline-browser-mapping@latest -D`
    ‘‘‘

  • ‘‘‘ ##[error][ERROR] SonarQube Cloud: Error while executing task Analyze: The process ‘/home/vsts/work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/3.4.3/sonar-scanner/bin/sonar-scanner’ failed with exit code 3

    ##[error]The process ‘/home/vsts/work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/3.4.3/sonar-scanner/bin/sonar-scanner’ failed with exit code 3

    ‘‘‘

  • Steps to reproduce - Intermittent Issue, Raise a PR and add any component, the validation pipeline passes and fails in the deployment pipeline. The deployment pipeline runs all apex tests in the target org and sends the coverage report to Sonar. That is when the issue happens with the following errors received, and sonar shows 0 coverage for a few specific classes(everytime the same set of classes) even when the coverage file we are sending has more than 80% coverage for all those classes

  • Potential workaround - No workaround identified yet

Hi,

Welcome to the community and thanks for this report!

Could we have the full analysis log, starting from the analysis command itself, please?

 
Thx,
Ann

Hi Ann, Thank you. PFA the analysis log.

SonarIssue.log (1.4 MB)

Hi,

Thanks for the log. It indicates that analysis itself succeeded. What failed was your quality gate status:

This doesn’t happen by default. Someone in your organization has configured it to act this way.

The easiest thing to do is check the project in SonarQube Cloud and make the changes needed to pass the quality gate.

 
HTH,
Ann

Template for a good new topic, formatted with Markdown:

  • ALM used -Azure DevOps

  • CI system used - Azure DevOps

  • Languages of the repository - English

  • Error observed - ‘‘‘ ##[error]17:28:46.735 ERROR QUALITY GATE STATUS: FAILED - View details on Sonarcloud‘‘‘

  • ‘‘‘ ##[error][ERROR] SonarQube Cloud: Error while executing task Analyze: The process ‘/home/vsts/work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/3.4.3/sonar-scanner/bin/sonar-scanner’ failed with exit code 3

    ##[error]The process ‘/home/vsts/work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/3.4.3/sonar-scanner/bin/sonar-scanner’ failed with exit code 3

    ‘‘‘

  • Steps to reproduce - Raise a PR with some changes to an Apex class already present in the repo. The Sonar validation fails and when i go to. SonarCloud to check the issue, it says coverage of the class is less even when the coverage file being sent has coverage.

  • Potential workaround - Delete the apex class from the repo and add it back in a separate PR

Hi again,

FYI, I’ve combined your topics since they’re about the same thing.

 
Ann

Hi Ann, the quality gate check that fails is that the coverage should be greater than 80%. When i check which classes are showing less coverage in Sonar, there is a set of 7-8 classes which show 0 coverage, even though these classes have coverage more than 80% in the actual orgs. I have even run these test classes in deployment users context and they still show greater than 80% coverage. So i am struggling to understand why these classes show 0% coverage in Sonar? Also this issue is intermittent.

The other topic i created was for a similar but separate issue i believe, attaching the analysis log. This log gives me an error - ERROR Invalid coverage information on file: ‘PAH_InvokeSubflow_ClaimAssmtRule’. But when i check the coverage file, it has coverage for this class included which is greater than 80%, and this coverage file is auto generated from the sf cli command recommended to be used by Sonar

SonarLogInvalidCoverage.log (4.6 KB)

Hi,

The full error is:

How many lines does PAH_InvokeSubflow_ClaimAssmtRule.cls have?

 
Ann