侧边栏壁纸
博主头像
faneok博主等级

重剑无锋,大巧不工

  • 累计撰写 33 篇文章
  • 累计创建 17 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

SonarScanner CLI

faneok
2024-09-10 / 0 评论 / 0 点赞 / 73 阅读 / 5251 字

下载安装包

macOS and Linux AArch64 distributions

Download scanner for:Linux x64Linux AArch64Windows x64macOS x64macOS AArch64DockerAny (Requires a pre-installed JVM)

Release notes

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-8

Running SonarScanner CLI from the zip file

To run SonarScanner CLI from the zip file, follow these steps:

  1. Expand the downloaded file into the directory of your choice. We'll refer to it as <INSTALL_DIRECTORY> in the next steps.

  2. 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

  3. Add the <INSTALL_DIRECTORY>/bin directory to your path.

  4. Verify your installation by opening a new shell and executing the command sonar-scanner -h, or sonar-scanner.bat -h on 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.

  5. 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 the SONAR_TOKEN environment variable and set the token as its value before you launch the analysis.

0

评论区