Dimensions Pulse에서 SonarQube expert 설정하기
SonarQube는 오픈소스 품질관리 플랫폼으로 소스코드의 기술적 품질에 대한 연속적인 분석 및 측정을 합니다.
Dimensions CM은 SonarQube와 쉽게 연계가 가능하도록 SonarQube expert를 번들로 탑재하고 있습니다. 이를 통해 리파지토리의 소스코드의 정적 분석을 수행하여 분석 결과 및 매트릭스 리포트를 확인할 수 있습니다. 소스코드가 리파지토리에 반영될 때마다 실행할 수 있으며 또는 정기적인 스케쥴을 정해 실행할 수 있습니다.
테스트 환경:
Dimensions CM 14.3
SonarQube 5.0.1
http://downloads.sonarsource.com/sonarqube/sonarqube-5.0.1.zip
SonarQube Scanner 2.6.1
https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-2.6.1.zip
필수 준비사항:
1. SonarQube Scanner 프로그램을 Dimensions CM 설치된 동일 서버에 설치합니다.
2. SonarQube expert 설정 파일을 아래 경로와 같이 만듭니다.
${dataDir}/conf/experts/com.serena.starlight/sonarqube/sonarqube-pulse-expert.properties
3. 생성된 프로퍼티 파일에 아래와 같이 SonarQube 호스팅서버와 Scanner 정보를 입력합니다.
sonar.host.url=http://localhost:9000 pulse.sonar.agent.path=C:\\sonar-scanner-2.6.1\\bin\\sonar-scanner.bat #sonar.jdbc.url=jdbc:oracle:thin:@localhost:1521:dim14 #sonar.jdbc.username=sonar #sonar.jdbc.password=sonar #pulse.results.delay=30
첫번째, 두번째 줄은 필수항목이고 나머지는 입력하지 않으면 ${SONAR_SCANNER_HOME}/conf/sonar-runner.properties 파일에 지정된 기본값을 사용합니다.
Expert Chains 설정방법:
1. Dimensions Pulse 화면에 접속합니다. 예) http://localhost:8080/pulse
2. SonarQube와 연계를 원하는 프로젝트 또는 스트림으로 이동합니다.
3. 왼쪽 메뉴에서 Expert Chains를 선택합니다.
4. 새로운 Expert Chain을 등록하기 위해 'New Expert Chain' 버튼을 누릅니다.
5. Expert 타이틀을 입력합니다.
6. 'Experts in Chain' 탭을 선택 후 'Add Expert' 버튼을 눌러 'SonarQube'를 선택합니다.
7. SonarQube expert 사용을 위한 필수항목 필드를 채우고 저장합니다.
필드명 | 설명 | 필수항목 | Example |
Title | Expert 타이틀 |
Yes | SonarQube |
Username | SonarQube 서버 username을 입력 | No | admin |
Password | SonarQube 서버 password을 입력 |
No | admin |
Analysis mode | analysis mode 선택:
버전별로 상이할 수 있습니다. 현재 SonarQube 5.0.1 기준으로 작성되었습니다. |
Yes | analysis |
Project name | SonarQube 프로젝트명 일반적으로 Maven에서 <name>으로 선언된 값 |
Yes | my_project |
Project key | 고유의 SonarQube project key 일반적으로 Maven에서 <groupId>:<artifactId>으로 선언된 값 |
Yes | example-key or com.example:project1 |
Project version | SonarQube project version 일반적으로 Maven에서 <version> 으로 선언된 값 |
Yes | 1.0 |
Source folder | 분석대상 소스코드의 상대 경로위치 |
Yes | src/main/java |
예)
SonarQube expert 실행결과:
SonarQube에 의한 분석 결과물과 매트릭스 정보를 확인할 수 있습니다.
Analysis 결과가 소스코드에 직접 표기되어 개발자가 손쉽게 검토할 수 있도록 합니다.
참고자료:
http://help.serena.com/doc_center/cm/ver143/pulse/onlinehelp.html#reference_sonarqube
https://www.serenacentral.com/blogs/entry/new-in-14-2-pulse-sonar-qube-expert-analysis