Azure Devops: Please provide compiled classes of your project with sonar.java.binaries property

Hi,

I’m facing below issue while executing Azure CI-Pipeline in Azure Devops.

INFO: ------------------------------------------------------------------------
INFO: Total time: 10.439s
INFO: Final Memory: 22M/77M
INFO: ------------------------------------------------------------------------
##[error]ERROR: Error during SonarQube Scanner execution
org.sonar.java.AnalysisException: Please provide compiled classes of your project with sonar.java.binaries property
at org.sonar.java.JavaClasspath.init(JavaClasspath.java:64)
at org.sonar.java.AbstractJavaClasspath.getElements(AbstractJavaClasspath.java:280)
at org.sonar.java.SonarComponents.getJavaClasspath(SonarComponents.java:209)

The pipeline setup is using sonar-project.properties for executing sonar-scanner.

Required metadata

sonar.projectKey=Self-Learning
sonar.projectName=Self-Learning
sonar.projectVersion=1.0

Comma-separated paths to directories with sources (required)

sonar.sources=src
sonar.java.binaries=target/doctor*jar

Language

sonar.language=java

Encoding of the source files

sonar.sourceEncoding=UTF-8

The Azure-Pipeline is configured as below :

  • task: Maven@3
    inputs:
    mavenPomFile: ‘pom.xml’
    publishJUnitResults: false
    testResultsFiles: ‘**/surefire-reports/TEST-*.xml’
    javaHomeOption: ‘JDKVersion’
    jdkVersionOption: ‘1.11’
    mavenVersionOption: ‘Default’
    mavenAuthenticateFeed: false
    effectivePomSkip: false

  • task: SonarQubePrepare@4
    inputs:
    SonarQube: ‘Self-Learning-Sonar’
    scannerMode: ‘CLI’
    configMode: ‘file’

  • task: SonarQubeAnalyze@4

Please help on this issue.

Thanks.

Hi,

Since you are passing sonar.java.binaries, then it might be useful to try with sonar.scanner.dumpToFile=[a file name] (details in the docs) to see exactly what gets to the scanner.

 
Ann

Thanks Ann for your prompt reply.
I was doing a mistake passing build *jar file to sonar.binaries.
Instead the path to classes directory where compiled class files gets generated fixed this issue.

sonar.binaries=/path/to/classes/directory

Currently the scanner is able to scan test cases but code coverage is reported 0.
And when I pass a testreport.xml, it fails in parsing
sonar.coverageReportPaths=target/surefire-reports/TEST-com.package-name.MasterListControllerTest.xml

I’ll try to figure out the issue. Meanwhile any suggestion is highly appreciated.

Thanks,
Debadatta

Hi Debadatta,

I’m glad you worked through the binaries problem. For coverage, it’s best to start a new thread.

 
:slightly_smiling_face:
Ann