I do use PublishCodeCoverageResults@2
task in my Azure DevOps pipeline
- task: PublishCodeCoverageResults@2
inputs:
codeCoverageTool: 'JaCoCo'
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/target/site/jacoco-aggregate/**/jacoco.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)/target/site/jacoco-aggregate/'
pathToSources: '$(System.DefaultWorkingDirectory)/**/src/main/java/'
failIfCoverageEmpty: false
Everything works nicely but the odd thing is – while running this task the Code Coverage shows me the Jacoco html reports, view looks like this
and here the Code Coverage View after the pipeline finished
The second view is not useful, cause you can’t navigate into the class and see the code, while with the jacoco html reports this is possible.
What am I doing wrong? Or why is the view changing? How can I avoid this behaviour?
2
Answers
I can see two possible things that might be wrong.
There are two versions of this task available with slightly different syntax. You’re using inputs (
codeCoverageTool
,reportDirectory
) that aren’t available in version 2. These "illegal" properties are ignored at runtime and have no effect.The syntax between versions:
PublishCodeCoverageResults@1
PublishCodeCoverageResults@2
Both the v1 and v2 documentation states that the
pathToSources
must be an absolute path:Remove the wildcards
**
in yourpathToSources
to ensure the report is properly generated. The variable$(System.DefaultWorkingDirectory)
represents an absolute path to the root of your repository.