'Azure Devops pipeline not publishing code coverage results in Sonarcloud

We have a Maven project and it will be executed in Azure Devops pipeline. Recently we configured Sonarcloud for Analysis and Code coverage, and the Analysis is happening and code coverage always shows as 0.0% but the test cases are executed during execution.

- task: SonarCloudPublish@1
  inputs:
    pollingTimeoutSec: '300'
- task: PublishCodeCoverageResults@1
  inputs:
    codeCoverageTool: 'JaCoCo'
    summaryFileLocation: '**/jacoco-aggregate/jacoco.xml'

I have used PublishCodeCoverageResults task and came to know this will be used to publish coverage in Azure itself. But Which task in Azure has to be used for publishing in Sonarcloud ? Can someone provide inputs on the same ? Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source