Programming/iOS

Tomcat+Jenkins+SonarQube for OSX

알레아 2016. 6. 2. 11:09
반응형

OSX 상에서 SonaQube에 Jeknins를 연동하여 SonaQube 코드품질 측정을 자동으로 하도록 설치하는 과정입니다.
또한 Tomcat으로 SonarQube를 띄워 서버가 돌아가도록 하는 과정도 포함 했습니다.

 

설치 순서는
mysql > SonaQube > Jenkins

 

주의

각각의 패키지 설치는 Homebrew를 통해 진행하였습니다.
혹시 아직 Homebrew가 설치 돼 있지 않으면, 해당 패키지를 설치 한 후, 아래 설치를 진행합니다.

 

설치

mysql

mysql 설치

$ brew install mysql
$ brew services start mysql

 

처음 설치 했다면 root 암호 설정

$ mysqladmin -u root -p password root

 

sonarQube 계정 설정을 위해 sql 실행

$ mysql -u root -p < create_database.sql

파일 > create_database.sql

 

SonarQube

sonar 설치

$ brew install sonar
$ brew install sonar-runner

 

sonar property 설정

$ vi /usr/local/Cellar/sonar/5.6/libexec/conf/sonar.properties

 

수정부분

# User credentials.
# Permissions to create tables, indices and triggers must be granted to JDBC user.
# The schema must be created first.
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
#----- MySQL 5.6 or greater
# Only InnoDB storage engine is supported (not myISAM).
# Only the bundled driver is supported. It can not be changed.
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance

 

sonar 실행

$ brew services start sonar

 

Jenkins

Jenkins 설치

$ brew install jenkins
$ brew services start jenkins

 

서비스 시작 확인

mysql, Sonar, Jenkins가 모두 설치 및 서비스가 실행됐는지 확인하기 위해 서비스를 확인

$ brew services list

 

 

해당 서비스가 모두 실행중이라면 설치 완료!!

 

만약 mysql이 실행이 안됐다면

$ mysql.server start

 

 

SonarQube+Jenkins 설정

Jenkins에서 SonarQube를 설정하고 자동 측정하는 방법입니다.

  1. Jenkins내 SonarQube plugin 설치

  2. SonaQube 설정

    Jenkins 관리 -> 시스템 설정 -> SonarQube servers -> Enable injection of SonarQube server configuration as build environment variables 체크 -> name 설정

  3. SonarQube Scanner 설정

    Jenkins 관리 -> Global Tool Configuration -> SonarQube Scanner -> Install automatically 체크, 최신버전 선택

  4. 해당 프로젝트 설정

    Add build step -> Excute SonarQube Scanner

    Analysis properties에 프로젝트 정보 기입

sonar.projectKey=com.magicmon.testapp
sonar.projectName=testapp
sonar.projectVersion=1.0.0
sonar.sources=testapp

 

 

참고사이트

if Error

http://stackoverflow.com/questions/33843378/sonar-fails-to-connect-to-mysql-on-mac-ei-caption
http://stackoverflow.com/questions/28988441/cant-acess-sonarqube-not-a-valid-locale

반응형