Sonar: You must define the following mandatory properties for unknown not resolved
Asked Answered
A

4

20

I'm trying to run SonarQube on a project in java. I configured the sonar properties file and placed it in the project directory. On running the sonar.bat there is an error that asks to define the mandatory parameters. At first I assumed my properties file was wrong, but I've tried everything I can think of.

this is the current properties file

# Required metadata
sonar.projectKey=_newtest2
sonar.projectName=NoSqlDataModeling
sonar.projectVersion=2.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 sonar.modules is set. 
# If not set, SonarQube starts looking for source code from the directory containing 
# the sonar-project.properties file.
sonar.sources=D:/eclipse workspace/NoSqlDataModeling


#Comma-separated paths to directories containing the binary files (directories with class files, in the case of Java).
sonar.binaries=D:/eclipse workspace/NoSqlDataModeling/build/classes

#Comma-separated paths to files with third-party libraries (JAR files in the case of Java). Patterns #can be used.
sonar.libraries=D:/eclipse workspace/NoSqlDataModeling/WebContent/WEB-INF/lib/*.jar

#language used
sonar.language=java

# Encoding of the source code
sonar.sourceEncoding=UTF-8

# Additional parameters
sonar.my.property=value

this is the error message

INFO: SonarQube Server 4.3.1
09:58:57.783 INFO  - Load batch settings
09:58:57.901 INFO  - User cache: C:\Users\Rohan.Kumar\.sonar\cache
09:58:57.907 INFO  - Install plugins
09:58:57.913 INFO  - Download sonar-maven-batch-plugin-4.3.1.jar
09:58:58.037 INFO  - Download sonar-findbugs-plugin-2.1.jar
09:58:58.436 INFO  - Download sonar-surefire-plugin-2.1.jar
09:58:58.540 INFO  - Download sonar-cpd-plugin-4.3.1.jar
09:58:58.870 INFO  - Download sonar-core-plugin-4.3.1.jar
09:58:58.956 INFO  - Download sonar-java-plugin-2.1.jar
09:58:59.097 INFO  - Download sonar-dbcleaner-plugin-4.3.1.jar
09:58:59.216 INFO  - Download sonar-jacoco-plugin-2.1.jar
09:58:59.331 INFO  - Download sonar-l10n-en-plugin-4.3.1.jar
09:58:59.350 INFO  - Download sonar-squid-java-plugin-2.1.jar
09:58:59.453 INFO  - Download sonar-email-notifications-plugin-4.3.1.jar
09:58:59.655 INFO  - Download sonar-design-plugin-4.3.1.jar
09:58:59.826 INFO  - Install JDBC driver
09:59:00.061 WARN  - H2 database should be used for evaluation purpose only
09:59:00.061 INFO  - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
09:59:00.784 INFO  - Initializing Hibernate
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 7.521s
Final Memory: 5M/19M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: You must define the following mandatory properties for 'Unknow
n': sonar.projectKey, sonar.projectName, sonar.projectVersion, sonar.sources
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with t
he -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.

Should I provide comma separated paths to all the class files and java files? Till what depth do I provide the paths? the different class files are located in build/classes/.../.../<4 different folders that have class files inside them> I change the project key every time as I read it has to be unique.

Adali answered 29/9, 2014 at 4:55 Comment(7)
Did you see the answer at #21204850? It looks like the same problem you are having.Deuce
Nick, Yes i have and i modified the properties file too. Still didn't workAdali
@Karthikeyan, thanks for the edit. I'm new to stack overflowAdali
You might try putting the path values in quotes where there are spaces present. Like changing this, sonar.sources=D:/eclipse workspace/NoSqlDataModeling, to this sonar.sources="D:/eclipse workspace/NoSqlDataModeling"Deuce
hey nick, nope that didn't work.I got my hands on another properties file which seems to be working fine. It's much simpler too. but i can't see the difference between the two config files. Here is the new config file. if you could point out what errors i was makingAdali
# Required metadata sonar.projectKey=rohan_key2 sonar.projectName=NoSqlData sonar.projectVersion=1.2 # Comma-separated paths to directories with sources (required) sonar.sources=src sonar.binaries=build/classes # Language sonar.language=java # Encoding of the source files sonar.sourceEncoding=UTF-8 #sonar.devcockpit.userAutoMapping=true #sonar.scm.enabled=trueAdali
I got similar issue when using cygwin to run the command. I ran sonar-runner from command prompt and everything started working.Testes
S
16

How to Upload a Project to SonarQube:

1) Startup SonarQube. You should be able to see it if you type localhost:9000 into your browser.

2) In command prompt, cd to the directory of your project enter image description here

3) Make sure the root folder of your project has “sonar-project.properties” file and that it is configured. If your project doesn’t have the “sonar-project.properties” file, it will get this error= Sonar Setup Undefined Mandatory Properties

My “sonar-project.properties” file for my VendingMachineEmulator app looks like this: enter image description here

4) In command prompt, now type “C:\sonar-scanner\sonar-scanner-2.6.1\bin\sonar-scanner.bat”. Alternatively, you could’ve also type “C:\sonar-scanner\sonar-scanner-2.6.1\bin\sonar-runner.bat” too. I’m not sure what the difference is. Make sure the directory you are in is still the main folder of your project.

5) Done! Refresh localhost:9000 and check if the project is there.

Spermicide answered 11/7, 2016 at 16:34 Comment(1)
Same as above Answer along with few more sonar properties sonar.projectKey=MyWebApp sonar.projectBaseDir=./MyWebApp sonar.projectName=MyWebApp sonar.projectVersion=1.0 sonar.sources=./src/main/java sonar.language=java sonar.java.binaries=. sonar.scm.disabled=True sonar.sourceEncoding=UTF-8Filibertofilibuster
F
6

Those who are getting "EXECUTION FAILURE" on running sonar-runner in the project folder add

-Dproject.settings=./sonar-project.properties

As it can't able to find setting file, you have to mention it explicitly

sonar-project.properties is the file name in my project where I have gave projectKey, projectName

For me, Run sonar runner with the above mentioned argument. Sonar runner was there in the folder path sonar-plugin\agent\sonar-plugin-agent\sonar-qube-runner\bin\sonar-runner or add it in environment path

sonar-runner -Dproject.settings=./sonar-project.properties

Filature answered 25/9, 2018 at 13:53 Comment(2)
You rock dude. For bamboo users, I added to "Additional parameters" the value: -Dproject.settings=./sonar-project.properties Thank you.!!Forgiveness
I'm glad I could helpFilature
S
4

Try running sonar-scanner command from the directory where sonar-project.properties lies.

I faced same problem and later found I was running the command from the different directory.

Spinet answered 28/11, 2017 at 11:25 Comment(0)
I
0

I had this problem and in my case I didn't have the sonar-project.properties file in the root of my project, just create it and enter the properties in it according to your project.

Impeachment answered 28/6, 2024 at 23:59 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.