By SonarSource – GNU LGPL 3 – Issue Tracker – Sources Download SonarQube Scanner 3.0.3 Linux 64 bit Windows 64 bit Mac OS X 64 bit Any* *SonarQube 서버가 요구하는 버전의 자바 가상 머신(Java Virtual Machine, JVM)이 이미 시스템에 설치 되어 있다고 가정합니다. |
Panel | ||||||
---|---|---|---|---|---|---|
| ||||||
Table of Contents
|
Features
The SonarQube Scanner is recommended as the default launcher to analyze a project with SonarQube.
Installation
기능
SonarQube Scanner는 SonarQube로 프로젝트를 분석하는 가장 기본적인 방법입니다.
설치
- 압축된 파일을 임의의 위치에 다운로드한 뒤 압축을 해제합니다. 이수 이 디렉토리를 <install_diectory>로 표기합니다.
<install_directory>/conf/sonar-scanner.properties 파일을 수정하여 SonarQube 서버와의 연결을 설정합니다:
Code Block #----- Default SonarQube server #sonar.host.url=http://localhost:9000
- <install_directory>/bin
- 디렉토리를 path 환경 변수에 추가합니다.
sonar-scanner -h
(
Windows 플랫폼인 경우 sonar-scanner.bat -h)
명령을 실행하여 SonarQube Scanner가 정상적으로 설치되었는지 확인할 수 있습니다. 명령어 실행 결과는 아래와 같습니다:
Code Block 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
sonar.verbose
property by adding the command line parameter output
분석 과정에서 더 많은 로그 메시지를 표시하고자 하는 경우 command line 명령어 파라미터로 sonar.verbose
속성을 추가합니다: -Dsonar.verbose=true
Use
Create a configuration file in the root directory of the project:사용
프로젝트의 루트 디렉토리에, sonar-project.properties
환경 파일을 생성합니다:
Code Block | ||
---|---|---|
| ||
# 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. |
# This property is optional if sonar.modules is set. |
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:
프로젝트 루트 디렉토리에서 다음 명령을 실행하면, 프로젝트 분석을 수행합니다:
Code Block |
---|
sonar-scanner |
Project Samples
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.
Security
Any user who's granted Execute Analysis permission can run an analysis.
sonar.forceAuthentication
property is set to true)
, the analysis token of a user with Execute Analysis permission must be provided through the sonar.login
property. Example: sonar-scanner 샘플 프로젝트
github 디렉토리에서 샘플 프로젝트를 제공합니다. github 리포지토리의 샘플 프로젝트를 살펴보거나 다운로드할 수 있습니다. projects/language
디렉토리에서 샘플 프로젝트를 확인하십시오.
보안
분석을 수행하기 위해서는 Execute Analysis 권한을 가지고 있어야 합니다.
Anyone 그룹에 Execute Analysis 권한이 부여되어 있지 않거나, SonarQube 인스턴스의 인증 기능이 활성화 되어 있는 경우(forceAuthentication 속성값이 true
로 설정됨), Execute Analysis 권한을 부여받은 사용자의 토큰을 sonar.login 속성값으로 사용해야 합니다(예: sonar-sacnner -Dsonar.login=[my analysis token]
)
트러블 슈팅
Java heap space error or java.lang.OutOfMemoryError
,Increase the memory via the SONAR_SCANNER_
OPTS environment variableOPT 환경 변수 설정을 통해 메모리 증가:
Code Block |
---|
export SONAR_SCANNER_OPTS="-Xmx512m" |
Windows
환경의 경우, 쌍따옴표(")를 제외하고 아래와 같이 입력:
Code Block |
---|
set SONAR_SCANNER_OPTS=-Xmx512m |
Unsupported major.minor version
분석에 사용되는 Java 버전을 업그레이드하거나 네이티브 패키지를 활용함, SonarQube 5.6+
requires은 Java 8 이상을 필요로 함.
Going Further
Advanced SonarQube Scanner Usages더 읽어 보기
Child pages (Children Display) |
---|