CruiseControl 使用Ant启动tomcat后 cc为何不继续执行,手动关闭tomcat窗口,cc继续轮询下一次构建
因为项目需要做了一个CI服务器,使用的是CruiseContol+SVN+Ant,在CC的<schedule>中我配置了两个ant的脚本,一个是执行build的脚本,一个是执行release的脚本,build的时间间隔目前设置为3分钟,release是每天往web服务器上将build.xml打出的最新war包部署一次,代码如下:
<schedule interval="180">
<ant anthome="apache-ant-1.7.0" buildfile="projects/${project.name}/release.xml" time="1002"/>
<ant anthome="apache-ant-1.7.0" buildfile="projects/${project.name}/build.xml" />
</schedule>
我单独只放build脚本时CC正常,每隔3分钟构建一次,但加入release脚本后就出现了问题,我release.xml脚本如下:
<?xml version="1.0" encoding="UTF-8"?>
<project name="eadp" default="releaseok" basedir=".">
<property name="tomcatHome" value="E:\TDDOWNLOAD\apache-tomcat-6.0.33"/>
<property name="target" value="${basedir}/target"/>
<!-- 清理tomcat的work文件夹 ,原项目文件及war包-->
<target name="clean" depends="shutdowntomcat">
<delete dir="${tomcatHome}/work/Catalina/localhost/${ant.project.name}"/>
<delete dir="${tomcatHome}/webapps/${ant.project.name}"/>
<delete file="${tomcatHome}/webapps/${ant.project.name}.war"/>
</target>
<!-- 关闭tomcat -->
<target name="shutdowntomcat">
<!-- 调用tomcat shutdown命令强制关闭 -->
<exec executable="${tomcatHome}/bin/shutdown.bat" failonerror="false"></exec>
<!-- 休息30秒,等待关闭完成 -->
<sleep seconds="30"/>
</target>
<!-- 启动tomcat -->
<target name="startuptomcat" depends="copyWar">
<exec executable="cmd.exe" spawn="true" vmlauncher="false">
<env key="CATALINA_HOME" value="${tomcatHome}" />
<arg line="/c call ${tomcatHome}/bin/startup.bat" />
</exec>
</target>
<!-- 拷贝war至tomcat目录 -->
<target name="copyWar" depends="clean">
<copy file="${target}/${ant.project.name}.war" todir="${tomcatHome}/webapps"></copy>
</target>
<target name="releaseok" depends="startuptomcat">
<echo message="release eadp-web ok"></echo>
</target>
</project>
因为这个脚本中有打开tomcat的target,所以执行这个脚本时打开tomcat后,releaseok的target也能执行,也输出了内容,CC提示Build Success,但是并没有像build.xml脚本执行完成后CC输出的 next build in 3 minutes,查看logs里面的status.txt里面记录的是 2011-11-16T02:08:26 releaseok 就是我的release.xml的最后一个target,然后CC就停止在这里了,不继续轮询下一个构建,如果这时我手动关闭刚才ant打开的tomcat窗口,CC的控制台马上就有了反应,会正常输出下一次build的时间 然后一切就正常了。似乎CC是在等待打开的Tomcat窗口给它一个返回的信息,我如何能让ant执行的打开tomcat后让CC继续下一次构建呢?
CC的porject全配置如下
<project name="eadp-web">
<listeners>
<currentbuildstatuslistener file="logs/${project.name}/status.txt"/>
</listeners>
<bootstrappers>
<svnbootstrapper localWorkingCopy="projects/${project.name}" />
</bootstrappers>
<modificationset quietperiod="30">
<filesystem folder="projects/${project.name}"/>
</modificationset>
<schedule interval="180">
<ant anthome="apache-ant-1.7.0" buildfile="projects/${project.name}/release.xml" time="1248"/>
<ant anthome="apache-ant-1.7.0" buildfile="projects/${project.name}/build.xml" />
</schedule>
<log>
<merge dir="projects/${project.name}/target/test-results"/>
</log>
<publishers>
<onsuccess>
<artifactspublisher dest="artifacts/${project.name}" file="projects/${project.name}/target/eadp.war"/>
</onsuccess>
</publishers>
</project>
--------------------编程问答-------------------- CSDN真的没人了?
补充:Java , Java相关