Sonar-scanner fails during travis build : please consider upgrading to latest JaCoCo version

sonarcloud
jacoco

(Pascal Poizat) #1

Hello

I have an error when building a Java+Gradle project using Travis CI (see error log below).
It fails when using sonar-scanner.
My project (a very simple project for experimenting things) is :

Before (July 2018 from the activity tracked on SonarCloud) the build was ok (and data sent to SonarCloud) using these plugins:

  • org.jacoco:jacoco-maven-plugin:0.7.9
  • org.sonarqube.gradle:gradle-sonarqube-plugin:1.0

I tried to use new versions of the plugins but it is still failing:

  • org.jacoco:jacoco-maven-plugin:0.8.2
  • org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.7

Has someone also experienced this?

The error log is:

$ sonar-scanner
INFO: Scanner configuration file: /home/travis/.sonarscanner/sonar-scanner-3.0.3.778/conf/sonar-scanner.properties
INFO: Project root configuration file: /home/travis/build/pascalpoizat/template-java-project/sonar-project.properties
INFO: SonarQube Scanner 3.0.3.778
INFO: Java 1.8.0_151 Oracle Corporation (64-bit)
INFO: Linux 4.4.0-101-generic amd64
INFO: User cache: /home/travis/.sonar/cache
INFO: Publish mode
INFO: Load global settings
INFO: Load global settings (done) | time=730ms
INFO: Server id: BD367519-AWHW8ct9-T_TB3XqouNu
INFO: User cache: /home/travis/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=161ms
INFO: Load/download plugins (done) | time=298ms
INFO: Loaded core extensions: branch-scanner
INFO: SonarQube server 7.6.0
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Process project properties
INFO: Execute project builders
INFO: Execute project builders (done) | time=9ms
INFO: Load project branches
INFO: Load project branches (done) | time=129ms
INFO: Load project pull requests
INFO: Load project pull requests (done) | time=126ms
INFO: Load branch configuration
INFO: Load branch configuration (done) | time=7ms
INFO: Load project repositories
INFO: Load project repositories (done) | time=211ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=184ms
INFO: Load active rules
INFO: Load active rules (done) | time=3500ms
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=137ms
INFO: Project key: fr.uparis10.pascalpoizat:template-java-project
INFO: Project base dir: /home/travis/build/pascalpoizat/template-java-project
INFO: Organization key: pascalpoizat-github
INFO: -------------  Scan fr.uparis10.pascalpoizat:template-java-project
INFO: Base dir: /home/travis/build/pascalpoizat/template-java-project
INFO: Working dir: /home/travis/build/pascalpoizat/template-java-project/.scannerwork
INFO: Source paths: src/main
INFO: Test paths: src/test
INFO: Source encoding: UTF-8, default locale: en_US
WARN: Property 'sonar.abap.file.suffixes' is not declared as multi-values/property set but was read using 'getStringArray' method. The SonarQube plugin declaring this property should be updated.
INFO: Index files
INFO: 6 files indexed
INFO: Quality profile for java: Sonar way
INFO: Sensor JavaSquidSensor [java]
INFO: Configured Java source version (sonar.java.source): none
INFO: JavaClasspath initialization
WARN: Bytecode of dependencies was not provided for analysis of source files, you might end up with less precise results. Bytecode can be provided using sonar.java.libraries property.
INFO: JavaClasspath initialization (done) | time=14ms
INFO: JavaTestClasspath initialization
WARN: Bytecode of dependencies was not provided for analysis of test files, you might end up with less precise results. Bytecode can be provided using sonar.java.test.libraries property.
INFO: JavaTestClasspath initialization (done) | time=0ms
INFO: Java Main Files AST scan
INFO: 2 source files to be analyzed
INFO: 2/2 source files have been analyzed
INFO: Java Main Files AST scan (done) | time=815ms
INFO: Java Test Files AST scan
INFO: 2 source files to be analyzed
INFO: 2/2 source files have been analyzed
INFO: Java Test Files AST scan (done) | time=82ms
INFO: Sensor JavaSquidSensor [java] (done) | time=1802ms
INFO: Sensor SurefireSensor [java]
INFO: parsing [/home/travis/build/pascalpoizat/template-java-project/target/surefire-reports]
INFO: Sensor SurefireSensor [java] (done) | time=7ms
INFO: Sensor JaCoCoSensor [java]
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 14.051s
INFO: Final Memory: 73M/370M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
org.sonar.java.AnalysisException: You are not using the latest JaCoCo binary format version, please consider upgrading to latest JaCoCo version.
	at org.sonar.plugins.jacoco.JacocoReportReader.checkCurrentReportFormat(JacocoReportReader.java:87)
	at org.sonar.plugins.jacoco.JacocoReportReader.<init>(JacocoReportReader.java:49)
	at org.sonar.plugins.jacoco.UnitTestAnalyzer.readExecutionData(UnitTestAnalyzer.java:122)
	at org.sonar.plugins.jacoco.UnitTestAnalyzer.analyse(UnitTestAnalyzer.java:95)
	at org.sonar.plugins.jacoco.JaCoCoSensor.execute(JaCoCoSensor.java:77)
	at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:45)
	at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:88)
	at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:62)
	at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:74)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:164)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:319)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:314)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:288)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
	at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:82)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:131)
	at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
	at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:111)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:63)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	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:233)
	at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
	at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:123)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:77)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
ERROR: 
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
The command "sonar-scanner" exited with 1.

(Evgeny Mandrikov) #3

Hi,

I don’t know what you mean by

because in https://github.com/pascalpoizat/template-java-project/tree/98f223f89c55fdf0151fe23318f82f63a2be69e6 you have project that uses Gradle,
and hence uses JaCoCo Plugin for Gradle - https://docs.gradle.org/current/userguide/jacoco_plugin.html So that version of JaCoCo is either should be specified in build.gradle:

jacoco {
  toolVersion = '0.8.2'
}

or default will be used, which depends on version of Gradle, because JaCoCo Plugin for Gradle is part of Gradle project and its distribution. For example 0.8.1 is default in Gradle 4.7, which is BTW a way newer than Gradle 2.10 used in your project.


Furthermore https://github.com/pascalpoizat/template-java-project/blob/98f223f89c55fdf0151fe23318f82f63a2be69e6/.travis.yml#L26 clearly indicates that in Travis you use sonar-scanner and not sonarqube-gradle-plugin. To use the last one you should execute corresponding Gradle task - gradlew sonarqube.

Hope this helps.


(Pascal Poizat) #5

Hi Evgeny.

First of all a big thank you for your help.
I have now:

  • updated my gradle wrapper to 5.0
  • added the correct JaCoCo version in my gradle build file
  • used the sonarqube gradle target instead of sonar-scanner
  • also: corrected a wrong path in my sonar-project.properties and added some path set up in my .travis.yml

Indeed I used the information from here https://docs.travis-ci.com/user/sonarcloud/ and then updated the plugins (as explained in my post) without reading the new one documentation (my bad). I will update the README I wrote for my students so that they get the correct information to set up the use of SonarQube in local or using SonarCloud + Travis CI following the solutions you gave to me.

Again, a big thank to you for helping me on this.

Pascal