<div class="table-wrap"> <table style="line-height: 1.4285715;" class="confluenceTable"><tbody><tr><td class="highlight-grey confluenceTd" data-highlight-colour="grey"> By <a target="_top" href="https://www.sonarsource.com">SonarSource</a> – GNU LGPL 3 – <a target="_top" href="https://jira.sonarsource.com/browse/SQSCANNER">Issue Tracker</a> – <a target="_top" href="https://github.com/Sonarsource/sonar-scanner-cli">Sources</a> <br> <table> <tr><td colspan="4"> <strong>Download SonarQube Scanner 3.0</strong><br/> Compatible with SonarQube 5.6+ (LTS) </td></tr> <tr> <td> <a target="_top" href="https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.0.0.702-linux.zip">Linux 64 bit</a> </td><td> <a target="_top" href="https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.0.0.702-windows.zip">Windows 64 bit</a> </td><td> <a target="_top" href="https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.0.0.702-macosx.zip">Mac OS X 64 bit</a> <td> <a target="_top" href="https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.0.0.702.zip">Any*</a> </td> </tr> <tr><td colspan="4"><small>*This package expects that a JVM is already installed on the system - with same Java requirements as the SonarQube server.</small></td></td></tr> </table> </div> </td></tr></tbody></table></div> |
The SonarQube Scanner is recommended as the default launcher to analyze a project with SonarQube.
Update the global settings to point to your SonarQube server by editing <install_directory>/conf/sonar-scanner.properties:
#----- Default SonarQube server #sonar.host.url=http://localhost:9000 |
You can verify your installation by opening a new shell and executing the command sonar-scanner -h
(on Windows platform the command is sonar-scanner.bat -h
) . You should get output like this:
usage: sonar-scanner [options] Options: -D,--define <arg> Define property -e,--errors Produce execution error messages -h,--help Display help information -v,--version Display version information -X,--debug Produce execution debug output |
If you need more debug information you can add the sonar.verbose
property by adding the command line parameter -Dsonar.verbose=true
.
Create a configuration file in the root directory of the project: sonar-project.properties
# must be unique in a given SonarQube instance sonar.projectKey=my:project # this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1. sonar.projectName=My project sonar.projectVersion=1.0 # 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=. # Encoding of the source code. Default is default system encoding #sonar.sourceEncoding=UTF-8 |
Run the following command from the project base directory to launch the analysis:
sonar-scanner |
To help you get started, simple project samples are available for most languages on github. They can be browsed or downloaded. You'll find them filed under projects/languages.
java.lang.OutOfMemoryError
, Increase the memory via the SONAR_SCANNER_OPTS environment variable:
export SONAR_SCANNER_OPTS="-Xmx512m" |
On Windows environments, avoid the double-quotes, since they get misinterpreted and combine the two parameters into a single one.
set SONAR_SCANNER_OPTS=-Xmx512m |
Upgrade the version of Java being used for analysis. SonarQube 5.6+ requires Java 8.