Jenkins 用ant部署tomcat的web项目
1, 基本:项目名称 - 根据实际情况来起名
2, 源码管理:选Subversion,
3, 构建:选Invoke Ant
4,构建后操作:这里是发布war包到已运行的tomcat中
附:V8的ant配置文件build.xml
<?xml version="1.0" encoding="UTF-8" ?>
<project name="v8" default="junit-report" basedir=".">
<!--13windows服务器 :C:/app/apache-tomcat-8.0.33/lib(上传前修改) -->
<!--本机:/Users/firefly/Web服务器/apache-tomcat-8.0.33/lib -->
<property name="tomcat.lib" value="C:/app/apache-tomcat-8.0.33/lib" />
<property name="warPath" value="." />
<property name="src.dir" value="sourcecode/src" />
<property name="webRoot.dir" value="sourcecode/WebRoot" />
<property name="dest.dir" value="${webRoot.dir}/WEB-INF/classes" />
<property name="junit.case.path" value="${webRoot.dir}/WEB-INF/classes" />
<property name="junit.report.path" value="junitReport" />
<property name="src.extra.dir" value="eadpSrc" />
<property name="src.junit.dir" value="junitSrc" />
<property name="src.netSearch.dir" value="netSearchSrc" />
<property name="jdk.version" value="1.7" />
<path id="junit.classpath">
<fileset dir="${webRoot.dir}/WEB-INF/lib">
<include name="junit.jar" />
</fileset>
</path>
<path id="project.classpath">
<pathelement path="${dest.dir}" />
<fileset dir="${webRoot.dir}/WEB-INF/lib">
<include name="*.jar" />
</fileset>
<fileset dir="${tomcat.lib}">
<include name="*.jar" />
</fileset>
</path>
<target name="init">
<delete dir="${dest.dir}" />
<delete dir="${junit.report.path}" />
<mkdir dir="${dest.dir}" />
<mkdir dir="${junit.report.path}" />
</target>
<target name="compile" depends="init">
<javac target="${jdk.version}" source="${jdk.version}" srcdir="${src.extra.dir}" destdir="${dest.dir}" debug="on" includeantruntime="on" encoding="UTF-8">
<classpath refid="project.classpath" />
</javac>
<javac target="${jdk.version}" source="${jdk.version}" srcdir="${src.dir}" destdir="${dest.dir}" debug="on" includeantruntime="on" encoding="UTF-8">
<sourcepath path="${src.extra.dir}">
</sourcepath>
<classpath refid="project.classpath" />
</javac>
<javac target="${jdk.version}" source="${jdk.version}" srcdir="${src.netSearch.dir}" destdir="${dest.dir}" debug="on" includeantruntime="on" encoding="UTF-8">
<sourcepath path="${src.extra.dir}">
</sourcepath>
<sourcepath path="${src.dir}">
</sourcepath>
<classpath refid="project.classpath" />
</javac>
<antcall target="cpCfg" />
</target>
<target name="cpCfg">
<copy todir="${dest.dir}">
<fileset dir="${src.dir}">
<include name="*.properties" />
<include name="resource/**" />
<include name="initdb/**" />
<include name="*.sql" />
</fileset>
<fileset dir="${src.netSearch.dir}">
<include name="*.properties" />
<include name="resource/**" />
</fileset>
<fileset dir="${src.extra.dir}">
<include name="*.properties" />
<include name="resource/**" />
</fileset>
<fileset dir="${src.junit.dir}">
<include name="**/support/**" />
</fileset>
</copy>
</target>
<!-- junit 测试 -->
<target name="compileJunit" depends="compile">
<javac target="${jdk.version}" source="${jdk.version}" srcdir="${src.junit.dir}" destdir="${dest.dir}" debug="on" includeantruntime="on" encoding="UTF-8">
<classpath>
<pathelement path="${dest.dir}"/>
</classpath>
<classpath refid="project.classpath" />
</javac>
</target>
<target name="junit" depends="compileJunit">
<junit printsummary="true" fork="true">
<formatter type="xml" usefile="true" />
<batchtest fork="on" todir="${junit.report.path}" haltonfailure="no">
<fileset dir="${junit.case.path}">
<include name="com/eplugger/**/*Test.class" />
</fileset>
</batchtest>
<classpath refid="project.classpath" />
</junit>
</target>
<target name="junit-report" depends="junit">
<!-- 产生单元测试报表文档 -->
<junitreport todir="${junit.report.path}">
<fileset dir="${junit.report.path}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${junit.report.path}" />
</junitreport>
</target>
<target name="makewar" depends="compile">
<war warfile="${warPath}/ROOT.war" webxml="${webRoot.dir}/WEB-INF/web.xml">
<lib dir="${webRoot.dir}/WEB-INF/lib">
<include name="**" />
</lib>
<classes dir="${webRoot.dir}/WEB-INF/classes" />
<fileset dir="${webRoot.dir}" />
</war>
</target>
</project>