1、安裝和配置JAVA的jdk環境
到oracal網站http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html,下載java的jdk安裝包,如:jdk-7u55-windows-x64.exe
安裝jdk-7u55-windows-x64.exe,默認下一步即可(安裝路徑可以自定義)。
配置環境變量:
右擊"我的電腦"——>"屬性",在彈出的"系統屬性"選項面板中選擇"高級"選項卡,點擊"環境變量"按鈕,彈出"環境變量"面板,在系統變量中進行相應的配置即可。
1) JAVA_HOME:
C:\Program Files\Java\jdk1.7.0_55
2) JRE_HOME:
C:\Program Files\Java\jre7
3) CLASSPATH:
.;C\Program Files\Java\jdk1.7.0_55\lib\dt.jar;C\Program Files\Java\jdk1.7.0_55\lib\tools.jar;%TOMCAT_HOME%\bin;
4) TOMCAT_HOME
D:\apache-tomcat-7.0.54
5) PATH
PATH裏在最後位置添加:
C:\Program Files\Java\jdk1.7.0_55; %JAVA_HOME%\jre\bin;
6) Cmd窗口運行java-version:
出現java版本,則說明配置成功。
2、 安裝jenkins
到http://jenkins-ci.org/下載jenkins安裝包,如:http://mirror.xmission.com/jenkins/windows/jenkins-1.566.zip
解壓縮後,運行setup.exe,默認安裝,可以自定義安裝路徑。
安裝後,運行services.msc,查看jenkins·服務,開啓服務。
用瀏覽器訪問http://localhost:8080/就可以訪問到jenkins的頁面了。
3、 Maven安裝及配置
到http://maven.apache.org/download.cgi下載maven,如:apache-maven-3.2.1-bin.zip
解壓apache-maven-3.2.1-bin.zip,到任意路徑,如:d:\apache-maven-3.2.1
添加環境變量:
1) M2_HOME
D:\apache-maven-3.2.1
2) M2
%M2_HOME%\bin
3) MAVEN_OPTS
-Xms256m -Xmx512m
4) PATH
%M2%;%JAVA_HOME%\bin;
5) 在cmd窗口運行mvn –version
4、 ant安裝和配置
到http://ant.apache.org/bindownload.cgi下載ant,如:apache-ant-1.9.4-bin.zip
解壓apache-ant-1.9.4-bin.zip,到任意路徑,如:d:\apache-ant-1.9.4
添加環境變量:
1) PATH
在path最後添加:
D:\apache-ant-1.9.4\bin;
2) ANT_HOME
D:\apache-ant-1.9.4
3) 在cmd窗口運行ant –version
5、 sonar安裝和配置
到http://www.sonarqube.org/downloads/下載sonar,如:sonar-3.7.4.zip
解壓sonar-3.7.4.zip,到任意路徑,如:d:\sonar-3.7.4
1) 安裝mysql數據庫
創建數據庫和賬號
mysql>CREATE DATABASE sonar CHARACTERSET utf8 COLLATE utf8_general_ci;
mysql>grant all on sonar.* to sonar@'%'identified by 'sonar';
mysql>grant all on sonar.* tosonar@localhost identified by 'sonar';
mysql>flush privileges;
2) 修改sonar配置文件
修改D:\sonar-3.7.4\conf\sonar.properties,註釋掉原有的jdbc行,開啓mysql的jdbc連接行:
#----- Credentials
# Permissions to create tables and indexesmust be granted to JDBC user.
# The schema must be created first.
sonar.jdbc.username: sonar
sonar.jdbc.password: sonar
#----- Embedded database H2
# Note : it does not accept connectionsfrom remote hosts, so the
# SonarQube server and the maven pluginmust be executed on the same host.
# Comment the following line to deactivatethe default embedded database.
# sonar.jdbc.url: jdbc:h2:tcp://localhost:9092/sonar
# directory containing H2 database files.By default it's the /data directory in the SonarQube installation.
#sonar.embeddedDatabase.dataDir:
# H2 embedded database server listeningport, defaults to 9092
#sonar.embeddedDatabase.port: 9092
#----- MySQL 5.x
# Comment the embedded database anduncomment the following line to use MySQL
sonar.jdbc.url: jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
3) 啓動sonar
運行D:\sonar-3.7.4\bin\windows-x86-64\InstallNTService.bat,運行後sonar將被安裝成windows服務,我們可以到services.msc裏開啓sonar服務
4) 訪問
瀏覽器打開http://localhost:9000訪問sonar
6、 sonar-runner安裝和配置
到http://www.sonarqube.org/downloads/下載sonar-runner,如:sonar-runner-dist-2.4.zip,
解壓sonar-runner-dist-2.4.zip,到任意路徑,如:D:\sonar-runner-2.4
1) 配置sonar-runner配置文件
修改D:\sonar-runner-2.4\conf\sonar-runner.properties,更改賬號信息和數據源信息
#Configure here general information aboutthe environment, such as SonarQube DB details for example
#No information about specific projectshould appear here
#----- Default SonarQube server
sonar.host.url=http://localhost:9000
#----- PostgreSQL
#sonar.jdbc.url=jdbc:postgresql://localhost/sonar
#----- MySQL
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
#----- Oracle
#sonar.jdbc.url=jdbc:oracle:thin:@localhost/XE
#----- Microsoft SQLServer
#sonar.jdbc.url=jdbc:jtds:sqlserver://localhost/sonar;SelectMethod=Cursor
#----- Global database settings
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
#----- Default source code encoding
sonar.sourceEncoding=UTF-8
#----- Security (when'sonar.forceAuthentication' is set to 'true')
sonar.login=admin
sonar.password=admin
2) 添加環境變量:
SONAR_RUNNER_HOME
D:\sonar-runner-2.4
3) PATH
PATH變量最後添加:
D:\sonar-runner-2.4\bin;
4) 在cmd窗口運行sonar-runner.bat -h
7、 jenkins整合
訪問jenkins http://localhost:8080,註冊一個賬號,然後登陸jenkins,進入系統管理-系統設置:
1、JDK安裝
2、ant安裝
3、Maven安裝
Maven項目配置:
4、SVN配置
根據安裝的svn版本號選擇。
5、MSBuild安裝
默認沒有MSBuild(Microsoft.NET Framework)安裝選項,需要安裝插件
進入系統管理-管理插件-可選插件,在右上角 過濾 裏輸入MSBuild:
安裝插件,安裝後進入系統管理-系統設置,可以看到MSBuilde
6、Sonar runner安裝
默認沒有sonar安裝選項,需要安裝插件
進入系統管理-管理插件-可選插件,在右上角過濾 裏輸入sonar:
安裝插件,安裝後進入系統管理-系統設置,可以看到sonar runner、sonar
sonar runner配置如下:
sonar配置如下: