Java exception with zaproxy html report to sonarscanner at Azure Devops CI

I got Java error when adding zaproxy html report to sonarscanner at Azure Devops CI
```
- task: SonarQubePrepare@4
inputs:
SonarQube: ‘SonarqubeDevTest-ErcanTest’
scannerMode: ‘MSBuild’
projectKey: ‘ErcanTest’
projectName: ‘ErcanTest’
extraProperties: |
sonar.zaproxy.reportPath=(System.DefaultWorkingDirectory)/owaspzap/test-results.xml sonar.zaproxy.htmlReportPath=(System.DefaultWorkingDirectory)/owaspzap/report.html

```

Error:
`##[error]ERROR: Error during SonarScanner execution 
java.lang.UnsupportedOperationException: Can not add the same measure 
twice on [key=ErcanTest]: 
DefaultMeasure[component=[key=ErcanTest],metric=Metric[uuid=<null>,key=html_report,description=Report
 HTML,type=DATA,direction=0,domain=OWASP-ZAP,name=ZAP 
Report,qualitative=false,userManaged=false,enabled=true,worstValue=<null>,bestValue=<null>,optimizedBestValue=false,hidden=false,deleteHistoricalData=true,decimalScale=<null>],value=<html>
 <head> <META http-equiv="Content-Type" content="text/html; 
charset=UTF-8"> at 
org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
 at 
org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
 at 
org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
 at 
org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
 at 
org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
 at 
org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
 at 
org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
 at 
org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
 at 
org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:393)
 at 
org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:389)
 at 
org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:386)
 at 
org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)
 at 
org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
 at 
org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
 at 
org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:144)
 at 
org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
 at 
org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
 at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72) at 
org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66) at 
org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
 at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native 
Method) at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.base/java.lang.reflect.Method.invoke(Method.java:566) at 
org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
 at com.sun.proxy.$Proxy0.execute(Unknown Source) at 
org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
 at 
org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
 at org.sonarsource.scanner.cli.Main.execute(Main.java:112) at 
org.sonarsource.scanner.cli.Main.execute(Main.java:75) at 
org.sonarsource.scanner.cli.Main.main(Main.java:61) ERROR:  ##[error]The
 SonarScanner did not complete successfully The SonarScanner did not 
complete successfully ##[error]11:40:02.815  Post-processing failed. 
Exit code: 1 11:40:02.815  Post-processing failed. Exit code: 1 
##[error]The process '/usr/bin/dotnet' failed with exit code 1 `

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    sonarqube 8.5 community
  • what are you trying to achieve
    see zaproxy report on sonarqube
  • what have you tried so far to achieve this
    I’ve tried to add following line to CI but none of them got work.
sonar.sources=reports
sonar.zaproxy.report.dir=reports
sonar.sources=.
sonar.zaproxy.key=html_report_zap (I just made up this if there is conflict about key )
1 Like