cruisecontrol + vss搭建持续集成(Java)
cruisecontrol + vss搭建持续集成最常见的问题是no modifications,但是其实repository中有modifications。
通过跟踪cruisecontrol.log中的ss.exe history $/XXX平台/源代码/vsstest -R -Vd09-09-16;14:17~09-09-16;02:00 -Ybuilduser,buildpass -I-N在命令行中执行,发现日期和时间的格式不对,导致命令行中没有内容显示。当repository中有modifications时,正确的ss命令应该会在命令行输出修改的version信息
后来通过修改config.xml中<vss dateformat="yy-MM-dd" timeformat="HH:mm"... 中dateformat和timeformat的内容,就可以了。
下面贴出config.xml的内容
<?xml version="1.0" encoding="UTF-8"?>
<cruisecontrol>
<property name="anthome" value="apache-ant-1.7.0" />
<property name="vssdir" value="C:\Program Files\Microsoft Visual SourceSafe" />
<project name="vss_proj">
<bootstrappers>
<currentbuildstatusbootstrapper file="logs/${project.name}/${project.name}_current_build.txt" />
<vssbootstrapper vsspath="/xxxx平台/源代码/vss_proj" ssdir="${vssdir}"
serverpath="\\192.168.1.100\vss_proj" login="builduser,buildpass" localdirectory="projects/${project.name}" />
</bootstrappers>
<modificationset quietperiod="60">
<vss dateformat="yy-MM-dd" timeformat="HH:mm" serverpath="\\192.168.1.100\vss_proj" ssdir="${vssdir}"
vsspath="/xxxx平台/源代码/vss_proj" login="builduser,buildpass" />
</modificationset>
<schedule>
<ant anthome="${anthome}" antWorkingDir="projects/${project.name}" buildfile="build_cc.xml" target="dist" time="0920"/>
<ant anthome="${anthome}" antWorkingDir="projects/${project.name}" buildfile="build_cc.xml" target="dist.weekly" time="0910" day="Monday"/>
</schedule>
<log dir="logs/${project.name}" />
<publishers>
<currentbuildstatuspublisher file="logs/${project.name}/${project.name}_current_build.txt" />
<artifactspublisher dir="projects/${project.name}/dist/" dest="artifacts/${project.name}" />
<htmlemail mailhost="emailserver.com" returnaddress="emailuser@email.com"
skipusers="true" subjectprefix="每日构建"
buildresultsurl="http://192.168.1.100:8080/cruisecontrol/buildresults/${project.name}"
username="emailuser" password="emailpass" charset="UTF-8">
<always address="emailuser@email.com" />
<failure address="emailuser1@email.com,emailuser2@email.com" />
<success address="emailuser1@email.com,emailuser2@email.com" />
</htmlemail>
</publishers>
</project>
</cruisecontrol>
如果执行<ant>时出错,或者编译环境中ant版本比较老可能引起junit不能正常工作,这时可以在<ant>中指定anthome,
另外cruisecontrol支持对多个project的模版式管理plugin,参见http://cruisecontrol.sourceforge.net/main/plugins.html
在查看Modifications时会发现一个图标table_unknown.gif无法显示,因为CC没有提供该图标,可以这里下载table_unknown.gif
schedule下可以出现多个<ant>,如
<ant anthome="${anthome}" antWorkingDir="C:\cruisecontrol-bin-2.8.2\projects\vsstest" buildfile="build_cc.xml" target="dist"/>
<ant anthome="${anthome}" antWorkingDir="C:\cruisecontrol-bin-2.8.2\projects\vsstest" buildfile="build_cc.xml" target="dist.weekly" time="1400" day="Thursday"/>
下面描述ant的脚本build_cc.xml应该注意的问题:
1.config.xml的<modificationset>只会检查VSS中是否有modification,CC并不会去VSS中获取源码,所以需要在build_cc.xml中编写vssget的任务并调用
<target name="get.src" >
<vssget localPath="C:\cruisecontrol-bin-2.8.2\projects\vss_proj"
serverPath="\\192.168.1.100\vss_proj"
ssdir="C:\Program Files\Microsoft Visual SourceSafe"
recursive="true"
login="builduser,buildpass"
vsspath="/xxxx平台/源代码/vss_proj"
filetimestamp="modified" />
</target>
2.每日构建会产生很多的jar, zip文件,日积月累可能会占据很大磁盘空间,下面的target del.artifacts通过ant来定期删除2周之前的文件和文件夹
<property name="artifacts.dir" value="C:/cruisecontrol-bin-2.8.2/artifacts/vss_proj"/>
<tstamp>
<format property="del.artifacts.time" pattern="yyyyMMddHHmmss" offset="-2" unit="week" />
</tstamp>
<target name="del.artifacts">
<echo message="==== delete artifacts before ${del.artifacts.time} ===="/>
<delete dir="${artifacts.dir}" includeemptydirs="true">
<date when="before" datetime="${del.artifacts.time}" pattern="yyyyMMddHHmmss" />
</delete>
</target>
timestamp的用法参照http://ant.apache.org/manual/CoreTasks/tstamp.html
通过跟踪cruisecontrol.log中的ss.exe history $/XXX平台/源代码/vsstest -R -Vd09-09-16;14:17~09-09-16;02:00 -Ybuilduser,buildpass -I-N在命令行中执行,发现日期和时间的格式不对,导致命令行中没有内容显示。当repository中有modifications时,正确的ss命令应该会在命令行输出修改的version信息
后来通过修改config.xml中<vss dateformat="yy-MM-dd" timeformat="HH:mm"... 中dateformat和timeformat的内容,就可以了。
下面贴出config.xml的内容
<?xml version="1.0" encoding="UTF-8"?>
<cruisecontrol>
<property name="anthome" value="apache-ant-1.7.0" />
<property name="vssdir" value="C:\Program Files\Microsoft Visual SourceSafe" />
<project name="vss_proj">
<bootstrappers>
<currentbuildstatusbootstrapper file="logs/${project.name}/${project.name}_current_build.txt" />
<vssbootstrapper vsspath="/xxxx平台/源代码/vss_proj" ssdir="${vssdir}"
serverpath="\\192.168.1.100\vss_proj" login="builduser,buildpass" localdirectory="projects/${project.name}" />
</bootstrappers>
<modificationset quietperiod="60">
<vss dateformat="yy-MM-dd" timeformat="HH:mm" serverpath="\\192.168.1.100\vss_proj" ssdir="${vssdir}"
vsspath="/xxxx平台/源代码/vss_proj" login="builduser,buildpass" />
</modificationset>
<schedule>
<ant anthome="${anthome}" antWorkingDir="projects/${project.name}" buildfile="build_cc.xml" target="dist" time="0920"/>
<ant anthome="${anthome}" antWorkingDir="projects/${project.name}" buildfile="build_cc.xml" target="dist.weekly" time="0910" day="Monday"/>
</schedule>
<log dir="logs/${project.name}" />
<publishers>
<currentbuildstatuspublisher file="logs/${project.name}/${project.name}_current_build.txt" />
<artifactspublisher dir="projects/${project.name}/dist/" dest="artifacts/${project.name}" />
<htmlemail mailhost="emailserver.com" returnaddress="emailuser@email.com"
skipusers="true" subjectprefix="每日构建"
buildresultsurl="http://192.168.1.100:8080/cruisecontrol/buildresults/${project.name}"
username="emailuser" password="emailpass" charset="UTF-8">
<always address="emailuser@email.com" />
<failure address="emailuser1@email.com,emailuser2@email.com" />
<success address="emailuser1@email.com,emailuser2@email.com" />
</htmlemail>
</publishers>
</project>
</cruisecontrol>
如果执行<ant>时出错,或者编译环境中ant版本比较老可能引起junit不能正常工作,这时可以在<ant>中指定anthome,
另外cruisecontrol支持对多个project的模版式管理plugin,参见http://cruisecontrol.sourceforge.net/main/plugins.html
在查看Modifications时会发现一个图标table_unknown.gif无法显示,因为CC没有提供该图标,可以这里下载table_unknown.gif
schedule下可以出现多个<ant>,如
<ant anthome="${anthome}" antWorkingDir="C:\cruisecontrol-bin-2.8.2\projects\vsstest" buildfile="build_cc.xml" target="dist"/>
<ant anthome="${anthome}" antWorkingDir="C:\cruisecontrol-bin-2.8.2\projects\vsstest" buildfile="build_cc.xml" target="dist.weekly" time="1400" day="Thursday"/>
下面描述ant的脚本build_cc.xml应该注意的问题:
1.config.xml的<modificationset>只会检查VSS中是否有modification,CC并不会去VSS中获取源码,所以需要在build_cc.xml中编写vssget的任务并调用
<target name="get.src" >
<vssget localPath="C:\cruisecontrol-bin-2.8.2\projects\vss_proj"
serverPath="\\192.168.1.100\vss_proj"
ssdir="C:\Program Files\Microsoft Visual SourceSafe"
recursive="true"
login="builduser,buildpass"
vsspath="/xxxx平台/源代码/vss_proj"
filetimestamp="modified" />
</target>
2.每日构建会产生很多的jar, zip文件,日积月累可能会占据很大磁盘空间,下面的target del.artifacts通过ant来定期删除2周之前的文件和文件夹
<property name="artifacts.dir" value="C:/cruisecontrol-bin-2.8.2/artifacts/vss_proj"/>
<tstamp>
<format property="del.artifacts.time" pattern="yyyyMMddHHmmss" offset="-2" unit="week" />
</tstamp>
<target name="del.artifacts">
<echo message="==== delete artifacts before ${del.artifacts.time} ===="/>
<delete dir="${artifacts.dir}" includeemptydirs="true">
<date when="before" datetime="${del.artifacts.time}" pattern="yyyyMMddHHmmss" />
</delete>
</target>
timestamp的用法参照http://ant.apache.org/manual/CoreTasks/tstamp.html