aosapps / drone-sonar-plugin

The plugin of Drone CI to integrate with SonarQube (previously called Sonar), which is an open source code quality management platform.
MIT License
30 stars 51 forks source link

Your project contains .java files #17

Open firstsko opened 4 years ago

firstsko commented 4 years ago

INFO: EXECUTION FAILURE

47 | INFO: ------------------------------------------------------------------------ 48 | INFO: Total time: 6.901s 49 | INFO: Final Memory: 18M/119M 50 | INFO: ------------------------------------------------------------------------ 51 | ERROR: Error during SonarQube Scanner execution 52 | org.sonar.java.AnalysisException: Your project contains .java files, please provide compiled classes with sonar.java.binaries property, or exclude them from the analysis with sonar.exclusions property. 53 | at org.sonar.java.JavaClasspath.init(JavaClasspath.java:64) 54 | at org.sonar.java.AbstractJavaClasspath.getElements(AbstractJavaClasspath.java:280) 55 | at org.sonar.java.SonarComponents.getJavaClasspath(SonarComponents.java:149) 56 | at org.sonar.java.JavaSquid.(JavaSquid.java:81) 57 | at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:102) 58 | at

Hpareek07 commented 3 years ago

Any update on this issue ?

yahaha-yes commented 2 years ago

There are two way to deal the problem. 1、 Add the sonar-scanner.properties to the project root path and set usingProperties:true

  steps:
  - name: code-analysis
    image: aosapps/drone-sonar-plugin
    settings:
      sonar_host:
        from_secret: sonar_host
      sonar_token:
        from_secret: sonar_token
      usingProperties: true

2、Repackage the docker image, here is my Dockerfile and sonar-scanner.properties Note: I use the DroneCI to do the code-analysis so the sonar.java.binaries is /drone/src/target/classes

## Dockerfile

FROM harbor.sz/library/drone-sonar-plugin:latest
ARG SONAR_VERSION=4.7.0.2747
ARG SONAR_SCANNER_CLI=sonar-scanner-cli-${SONAR_VERSION}
ARG SONAR_SCANNER=sonar-scanner-${SONAR_VERSION}
COPY ./sonar-scanner.properties /bin/${SONAR_SCANNER}/conf
ENV PATH $PATH:/bin/${SONAR_SCANNER}/bin
ENTRYPOINT /bin/drone-sonar

## sonar-scanner.properties

#Configure here general information about the environment, such as SonarQube server connection details for example
#No information about specific project should appear here
#----- Default SonarQube server
#sonar.host.url=http://localhost:9000
#----- Default source code encoding
#sonar.sourceEncoding=UTF-8
sonar.java.binaries=/drone/src/target/classes

It's not a bug , the sonar-scanner require sonar.java.binaries when do the java code analysis but the default conf not supply it.