一、下载
1. maven:
项目管理工具,可以进行项目的编译、测试、布置、发布等
下载路径:http://apache.etoak.com/maven/binaries/apache-maven-2.2.1-bin.zip
2. continuum:
基本实现的功能:
定时(也可能手动)从SVN中下载项目进行编译,并生成编译后的报告给指定人员,生成的报告内容有:
1. commit人、commit时间
2. 编译环境
3. maven运行后的结果:包括编译、运行testcase、打包、布置等等的信息(可自定义配置)
4. 运行是否成功
5. 有online report
下载路径:http://apache.etoak.com/continuum/binaries/apache-continuum-1.2.3-bin.zip
二、安装maven
1. 解压apache-maven-2.2.1-bin.zip至其一目录,如:D:\Developer\maven,目录结构如下:
2. 设置环境变量:
M2_HOME= D:\Developer\maven
PATH=% M2_HOME%\bin;%path%
3. 测试是否安装成功:mvn –v
三、安装continuum
1. 解压apache-continuum-1.2.3-bin.zip至其一目录,如:D:\Developer\continuum,目录结构如下:
2. 安装SVN客户端(CollabNetSubversion-client-1.6.9-1.win32.exe)
略
3. 修改配置文件:
a) 修改D:\Developer\continuum\conf\jetty.xml,将validation_mail部分修改为:
<New id="validation_mail" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>mail/Session</Arg> <Arg> <New class="org.mortbay.naming.factories.MailSessionReference"> <Set name="user">[email protected]</Set> <Set name="password">******</Set> <Set name="properties"> <New class="java.util.Properties"> <Put name="mail.smtp.host">mail.china-channel.com</Put> <Put name="mail.from">[email protected]</Put> <Put name="mail.smtp.auth">true</Put> <Put name="mail.debug">false</Put> </New> </Set> </New> </Arg> </New>
b) 修改
D:\Developer\continuum\apps\continuum\WEB-INF\classes\META-INF\plexus\application.xml,修改from-mailbox与from-name部分:
<from-mailbox>[email protected]</from-mailbox> <from-name>zhaoxy1</from-name>
4. 运行continuum:
D:\Developer\continuum\bin\continuum.bat console
也可以将其安装至windows服务中,在开机时自动启动:D:\Developer\continuum\bin\continuum.bat install
D:\Developer\continuum\bin\continuum.bat start
5. 进入continuum:
访问网站:http://localhost:8080/continuum/
log详见: D:\Developer\continuum\logs\continuum.log
第一次使用需设置管理员帐号与密码
四、配置SVN commit后自动发邮件:
新增脚本:post-commit.bat,写入发邮件的代码,可参考以下:
http://hi.baidu.com/anydb/blog/item/4112d01aac5db4be4aedbc24.html
五、测试
1. 编写maven测试项目:
cd workspace
mvn archetype:create -DgroupId=com.oreilly -DartifactId=my-app
2. 修改pom.xml文件,红色部分为continuum的配置:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany.app</groupId> <artifactId>my-app</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>my-app</name> <url>http://maven.apache.org</url> <developers> <developer> <id>zhaoxunyong</id> <name>zhaoxunyong</name> <email>[email protected]</email> <url>http://mail.139.com</url> <organization>Sonatype</organization> <organizationUrl>http://www.35.cn</organizationUrl> <roles> <role>developer</role> </roles> <timezone>-6</timezone> </developer> </developers> <ciManagement> <system>continuum</system> <url>http://192.168.0.10:8080/continuum</url> <notifiers> <notifier> <type>mail</type> <sendOnError>true</sendOnError> <sendOnFailure>true</sendOnFailure> <sendOnSuccess>true</sendOnSuccess> <sendOnWarning>true</sendOnWarning> <address>[email protected]</address> </notifier> </notifiers> </ciManagement> <scm> <connection>scm:svn:http://192.168.0.10:81/svn/my-app</connection> </scm> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <build> <filters> <filter>src/main/filters/filter.properties</filter> </filters> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> </build> <properties> <my.filter.key>key!</my.filter.key> </properties> </project>
3. 上传maven项目:
4. 配置发邮件部分
5. 配置schedules,具体设置如linux下的cron
6. Build:系统会将build结果以mail方式通知对应的人员
具体内容如下:
Online report : http://localhost:8080/continuum/buildResult.action?buildId=69&projectId=36
Build statistics:
State: Ok
Previous State: Ok
Started at: 星期一 1 三月 2010 15:56:01 +0800
Finished at: 星期一 1 三月 2010 15:56:10 +0800
Total time: 9s
Build Trigger: Schedule
Build Number: 13
Exit code: 0
Building machine hostname: myserver
Operating system : Windows 2003(Service Pack 2)
Java Home version :
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode, sharing)
Builder version :
Apache Maven 2.2.1 (r801777; 2009-08-07 03:16:01+0800)
Java version: 1.6.0_14
Java home: D:\Java\jdk1.6\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 2003" version: "5.2" arch: "x86" Family: "windows"
****************************************************************************
SCM Changes:
****************************************************************************
Changed: zhaoxy1 @ 星期一 1 三月 2010 15:54:08 +0800
Comment:
Files changed:
/src/main/java/com/mycompany/app/App.java ( 24 )
****************************************************************************
Dependencies Changes:
****************************************************************************
No dependencies changed
****************************************************************************
Build Definition:
****************************************************************************
POM filename: pom.xml
Goals: clean install
Arguments: --batch-mode --non-recursive
Build Fresh: false
Always Build: false
Default Build Definition: true
Schedule: DEFAULT_SCHEDULE
Profile Name: maven
Description: Default Maven 2 Build Definition
****************************************************************************
Test Summary:
****************************************************************************
Tests: 1
Failures: 0
Errors: 0
Success Rate: 100
Total time: 0.047 s.
****************************************************************************
Output:
****************************************************************************
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building my-app
[INFO] task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}] [INFO] Deleting directory D:\continuum\data\working-directory\36\target
[INFO] [resources:resources {execution: default-resources}] [WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO] [compiler:compile {execution: default-compile}] [INFO] Compiling 1 source file to D:\continuum\data\working-directory\36\target\classes
[INFO] [resources:testResources {execution: default-testResources}] [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\continuum\data\working-directory\36\src\test\resources
[INFO] [compiler:testCompile {execution: default-testCompile}] [INFO] Compiling 1 source file to D:\continuum\data\working-directory\36\target\test-classes
[INFO] [surefire:test {execution: default-test}] [INFO] Surefire report directory: D:\continuum\data\working-directory\36\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.mycompany.app.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.046 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] [jar:jar {execution: default-jar}] [INFO] Building jar: D:\continuum\data\working-directory\36\target\my-app-1.0-SNAPSHOT.jar
[INFO] [install:install {execution: default-install}] [INFO] Installing D:\continuum\data\working-directory\36\target\my-app-1.0-SNAPSHOT.jar to C:\Documents and Settings\Administrator\.m2\repository\com\mycompany\app\my-app\1.0-SNAPSHOT\my-app-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 seconds
[INFO] Finished at: Mon Mar 01 15:56:10 CST 2010 [INFO] Final Memory: 12M/26M [INFO] ------------------------------------------------------------------------
****************************************************************************