下载安装包
macOS and Linux AArch64 distributions
Download scanner for:Linux x64Linux AArch64Windows x64macOS x64macOS AArch64DockerAny (Requires a pre-installed JVM)
Configuring your project
Create a configuration file in your project's root directory called sonar-project.properties.
# must be unique in a given SonarQube instance
sonar.projectKey=my:project
# --- optional properties ---
# defaults to project key
#sonar.projectName=My project
# defaults to 'not provided'
#sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Defaults to .
#sonar.sources=.
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8Running SonarScanner CLI from the zip file
To run SonarScanner CLI from the zip file, follow these steps:
Expand the downloaded file into the directory of your choice. We'll refer to it as
<INSTALL_DIRECTORY>in the next steps.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:9000Add the
<INSTALL_DIRECTORY>/bindirectory to your path.Verify your installation by opening a new shell and executing the command
sonar-scanner -h, orsonar-scanner.bat -hon Windows. You should get an output like this:usage: sonar-scanner [options]
Options:
-D,--define <arg> Define property
-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 one of the following to your command line:-X,--verbose, or-Dsonar.verbose=true.Run the following command from the project base directory to launch analysis and pass your authentication token:
sonar-scanner -Dsonar.token=myAuthenticationToken
Alternatively, instead of passing the token in your command line, you can create theSONAR_TOKENenvironment variable and set the token as its value before you launch the analysis.
评论区