Running Sonar without Source or Classes

I’m interested in running Sonar on a project I have that doesn’t include traditional source or binaries (.class files). The project is a collection of Kubernetes helm charts, and we’re using Cucumber BDD to execute test cases against the services those charts provide. An example would be testing Kafka.

We have Java projects that use Cucumber for BDD testing with Sonar. Sonar scans those projects source, .class files, and also imports the output of Cucumber.

We would like to continue this with the Helm only projects and use Sonar to bring the Cucumber BDD results into Sonar.

The problem we’re running into is that Sonar is erroring out if there’s no path set to .class files. Here’s the message.

INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 9.181s
INFO: Final Memory: 32M/932M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: Please provide compiled classes of your project with sonar.java.binaries property
ERROR: 
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.

I’ve looked through the command line options and the various sonar. properties and didn’t see anything that looked like it would help.

Short of creating a dummy .java and .class file, is there any way that I can run the sonar scanner (or some other sonar tool) to just bring in my BDD test results?

Hi,

When I read your title, I thought you were trolling us. :laughing:

Reading the body, it makes more sense.

You wouldn’t be getting this error if analysis didn’t find some .java files in the project. For instance, you can analyse PHP projects all day long and never see this. SonarJava got “turned on” but the presence of some file that it thinks it should analyze, and then its normal limitations / requirements kicked in.

So… the “right” thing to do would be to figure out why SonarJava is being invoked during analysis and either provide the relevant class files or remove the .java file. The easy thing to do is probably to set a file exclusion on **/*.java or to edit (at the project level only) which file extensions it pays attention to.

 
HTH,
Ann

Ann,

Thanks for replying. When someone first asked me about sonar scanning this project, I was a little surprised too.

I was under the impression that I had already gotten Sonar to bring in Cucumber/BDD reports. Now, I’m not so sure about that.

Can you tell me how or where cucumber would look to find cucumber (or any extrernal tool’s) reports? Here’s my complete output from my last run. The cucumber files are in bdd and I’ve verified that after the cucumber tests run, bdd/target exists along with a directory structure.

/home/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_Scanner_3.2/bin/sonar-scanner 
-Dsonar.projectKey=com.avaya.flextester:flex-tester 
-Dsonar.sources=bdd/target,target 
-Dsonar.tool=SonarQube Scanner 3.2 
-Dsonar.environment=sonar forge 
-Dsonar.projectName=eventing-kafka 
-Dsonar.projectVersion=1.0.0
INFO: Scanner configuration file: /home/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_Scanner_3.2/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 3.2.0.1227
INFO: Java 1.8.0_181 Oracle Corporation (64-bit)
INFO: Linux 4.1.12-124.20.3.el7uek.x86_64 amd64
INFO: User cache: /root/.sonar/cache
INFO: SonarQube server 6.7.6
INFO: Default locale: "en_US", source code encoding: "US-ASCII" (analysis is platform dependent)
INFO: Publish mode
INFO: Load global settings
INFO: Load global settings (done) | time=101ms
INFO: Server id: A7EE8CF2-AWeMtm0Iu2cVOa_u6A6Z
INFO: User cache: /root/.sonar/cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=32ms
INFO: Download sonar-build-breaker-plugin-2.2.jar
INFO: Download sonar-cxx-plugin-1.1.0.jar
INFO: Download checkstyle-sonar-plugin-4.11.jar
INFO: Download sonar-cobertura-plugin-2.0.jar
INFO: Download coverity-sonar-plugin-1.6.2.jar
INFO: Download sonar-crowd-plugin-2.1.jar
INFO: Download sonar-findbugs-plugin-3.9.1.jar
INFO: Download sonar-scm-git-plugin-1.4.1.1128.jar
INFO: Download sonar-groovy-plugin-1.5.jar
INFO: Download sonar-pmd-plugin-3.1.2.jar
INFO: Download sonar-pitest-plugin-0.9.1.jar
INFO: Download sonar-csharp-plugin-7.9.1.7622.jar
INFO: Download sonar-javascript-plugin-5.0.0.6962.jar
INFO: Download sonar-java-plugin-5.9.2.16552.jar
INFO: Download sonar-kotlin-plugin-1.2.1.2009.jar
INFO: Download sonar-php-plugin-2.15.0.4060.jar
INFO: Download sonar-python-plugin-1.10.0.2131.jar
INFO: Download sonar-typescript-plugin-1.8.0.3332.jar
INFO: Download sonar-xml-plugin-1.5.1.1452.jar
INFO: Download sonar-scm-svn-plugin-1.8.0.1168.jar
INFO: Process project properties
INFO: Load project repositories
INFO: Load project repositories (done) | time=57ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=4ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=25ms
INFO: Load active rules
INFO: Load active rules (done) | time=625ms
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=15ms
INFO: Project key: com.avaya.flextester:flex-tester
INFO: -------------  Scan eventing-kafka
INFO: Base dir: /home/jenkins/workspace/ing_bdd-framework-blrcommon-UMKXBEBRSGDWQRK32VO4ODE5EUNTE3QZS6UCACSUMZ4P4O5WYHWA
INFO: Working dir: /home/jenkins/workspace/ing_bdd-framework-blrcommon-UMKXBEBRSGDWQRK32VO4ODE5EUNTE3QZS6UCACSUMZ4P4O5WYHWA/.scannerwork
INFO: Source paths: bdd/target, target
INFO: Source encoding: US-ASCII, default locale: en_US
INFO: Load server rules
INFO: Load server rules (done) | time=147ms
INFO: Index files
INFO: 37 files indexed
INFO: Quality profile for xml: Sonar way
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: 1 source files to be analyzed
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=45ms
INFO: Sensor XML Sensor [xml]
INFO: 1/1 source files have been analyzed
INFO: Sensor XML Sensor [xml] (done) | time=249ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=14ms
INFO: Sensor CPD Block Indexer
INFO: Sensor CPD Block Indexer (done) | time=0ms
INFO: SCM provider for this project is: git
INFO: 1 files to be analyzed
INFO: 0/1 files analyzed
WARN: Missing blame information for the following files:
WARN:   * bdd/target/surefire-reports/TEST-feature.SanityTest.xml
WARN: This may lead to missing/broken features in SonarQube
INFO: Calculating CPD for 0 files
INFO: CPD calculation finished
INFO: Analysis report generated in 86ms, dir size=82 KB
INFO: Analysis reports compressed in 6ms, zip size=21 KB
INFO: Analysis report uploaded in 13ms
INFO: ANALYSIS SUCCESSFUL, you can browse https://sonar.forge.avaya.com/dashboard/index/com.avaya.flextester:flex-tester
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at https://sonar.forge.avaya.com/api/ce/task?id=AWga-wxAlyIjvL9UBwNM
INFO: Task total time: 3.698 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 9.914s
INFO: Final Memory: 27M/711M
INFO: ------------------------------------------------------------------------

Hi,

To analyze cucumber files, you need a cucumber analyzer (“how much wood could a woodchuck chuck…”? :smile: ). Several years ago one was available in the community, but it was subsequently withdrawn by its author & I don’t believe it has been replaced. So… I’m not sure how/whether you really are analyzing cucumber files. I ignored the point in my initial response because it didn’t seem relevant to the main question.

 
Ann

Thanks. It was my error. I said I had it working in one case when I didn’t actually. I think I was mis-remembering jacoco; I know I’ve got that working. Anyhow, thanks for your help.

1 Like