Sonar Setup Undefined Mandatory Properties

Learning how to use SonarQube and was doing a quick install from here

Got all the way down to step 5. My build fails when I execute: C:\sonar-runner\bin\sonar-runner.bat

I get the following error:

INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 7.572s
Final Memory: 8M/223M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: You must define the following mandatory properties for 'Unknown':   sonar.projectKey, sonar.projectName, sonar.projectVersion, sonar.sources
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.

Anyone encountered a similar situation and resolved?

Answers


If you have a java project, you must create a sonar-project.properties file in the folder where you execute sonar runner. You must define the following properties inside this file:

# Required metadata
sonar.projectKey=java-sonar-runner-simple
sonar.projectName=Simple Java project analyzed with the SonarQube Runner
sonar.projectVersion=1.0

# Comma-separated paths to directories with sources (required)
sonar.sources=src

# Language
sonar.language=java

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

Hope this helps,


For me it was due to this: https://stackoverflow.com/a/18779516/1068411

In short: you should put sonar into "Post-Build Actions", not "Post-Build Steps".


For those who has similar response on CLI and guess thy setupped everything correctly, my problem was running sonar-runner command from out side of project directory. Make sure you have cd to your project and then run the command.


Inside Jenkins below sonar properties worked for me .

sonar.projectKey=MyWebApp
sonar.projectBaseDir=./MyWebApp
sonar.projectName=MyWebApp
sonar.projectVersion=1.0
sonar.sources=./src/main/java
sonar.language=java
sonar.java.binaries=.
##to avoid this exception Caused by: org.tmatesoft.svn.core.SVNAuthenticationException: svn: E170001
sonar.scm.disabled=True
sonar.sourceEncoding=UTF-8

Hope it will help someone. Thanks!


Need Your Help

Is there a way to make a PowerShell script work by double clicking a .ps1 file?

powershell powershell-2.0

I am distributing a PowerShell script to my team. The script is to fetch an IP address from the Vsphere client, make an mstsc connection, and log it in a shared file.

What happens when auto_increment on integer column reaches the max_value in databases?

database auto-increment integer-overflow lastinsertid

I am implementing a database application and I will use both JavaDB and MySQL as database. I have an ID column in my tables that has integer as type and I use the databases auto_increment-function ...