0
votes

We use Jenkins for both building application and running sonar analysis through maven on the code.

I am able create a local server, and run sonarqube analysis using sonar runner.

I was able to connect my eclipse instance to the company sonarqube runner and get the issues from existing analysis on eclipse. But while running 'Analyse' from eclipse, it fails.

It returns, You must define the following mandatory properties for 'Unknown': sonar.sources

While I looked into the process, I found that, a temporary sonar-runner is downloaded in the temp folder and a sonar-project.properties is created and the analysis is run using that. This property file does not have the sonar.sources defined inside it. Since this property file is not in my control, How to resolve this issue?

2
Just a suggestion: Is maven an option for you? Works fine from inside eclipse and can be used to run an analysis.Florian Schaetz
If you can let me know how to go about that..Godwin Joel
Well, you need your project to be a maven project, add some stuff (docs.sonarqube.org/display/SONAR/…) for SonarQube and then simply run the sonar:sonar goal.Florian Schaetz
Surely I'll try this too.. But they may not allow changing of project facet though.Godwin Joel
Well, maven is a big step, obviously, just for SonarQube it would be overkill. On the other hand, it has many advantages on it's own (if you are not yet using Gradle, of course).Florian Schaetz

2 Answers

1
votes

The sonar-project.properties config file must be in the root of your eclispe project. And it should looks like this:

# Required metadata
sonar.projectKey=nutch-key
sonar.projectName=nutch-prj
sonar.projectVersion=1.0
# Path to the parent source code directory.
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on   Windows.
# Since SonarQube 4.2, this property is optional. If not set, SonarQube starts looking for source code
# from the directory containing the sonar-project.properties file.
sonar.sources=src
# Encoding of the source code
sonar.sourceEncoding=UTF-8
# Additional parameters
sonar.my.property=value
0
votes

SQ Eclipse plugin will use the configured Eclipse (JDT) source folders and pass them to sonar.sources. Check that you have some source folders configured (Right click on project -> Properties -> Java build path).