之前说过很长一段时间内,我使用jenkins仅仅是涉及两个地方:配置svn版本,点击立即构建。
所以一直特别好奇jenkins的各个插件究竟是怎么工作的。然后最近研究了一下我这边用上的几个插件,虽然不够透彻,但好歹对jenkins的构建过程有了一定程度的了解^_^
Ant
jenkins是如何利用ant编译程序并打成war包的呢?ant是基于build.xml工作的。所以我研究了一下build.xml的具体内容:
【可参考http://www.cnblogs.com/xionghui/archive/2012/03/13/2393679.html,博主写的非常详细】
<?xml version="1.0" encoding="UTF-8"?> <project name="MyFirstJob" default="local" basedir="."> <property environment="env" /> <property name="src.dir" value="src" /> <property name="webroot.dir" value="WebContent" /> <property name="web-inf.dir" value="${webroot.dir}/WEB-INF" /> <property name="meta-inf.dir" value="${webroot.dir}/META-INF" /> <property name="configuration.dir" value="configuration" /> <property name="java.lib.dir" value="${env.JAVA_HOME}/lib" /> <property name="tomcat.lib.dir" value="${env.CATALINA_HOME}/lib" /> <property name="project.lib.dir" value="${web-inf.dir}/lib" /> <property name="output.dir" value="build/classes" /> <property name="release.dir" value="release" /> <property name="compile.debug" value="true" /> <property name="compile.deprecation" value="true" /> <property name="compile.optimize" value="true" /> <target name="clean"> <delete dir="${output.dir}" /> <delete dir="${release.dir}" /> <delete dir="${web-inf.dir}/classes}" /> </target> <path id="classpath"> <pathelement location="${output.dir}" /> <fileset dir="${java.lib.dir}"> <include name="*.jar" /> </fileset> <fileset dir="${tomcat.lib.dir}"> <include name="*.jar" /> </fileset> <fileset dir="${project.lib.dir}"> <include name="**/*.jar" /> </fileset> </path> <target name="compilesrc" depends="clean"> <mkdir dir="${output.dir}" /> <javac srcdir="src" destdir="${output.dir}" includeantruntime="false" deprecation="${compile.deprecation}" debug="${compile.debug}" optimize="${compile.optimize}" encoding="UTF-8"> <classpath refid="classpath" /> </javac> <copy todir="${web-inf.dir}/classes"> <fileset dir="${output.dir}" /> </copy> </target> <target name="local" depends="compilesrc"> <copy file="${configuration.dir}/web.config" tofile="${web-inf.dir}/classes/web.config" overwrite="true"/> <copy file="${configuration.dir}/algorithm.ini" tofile="${web-inf.dir}/classes/algorithm.ini" overwrite="true"/> <copy file="${configuration.dir}/web.xml" tofile="${web-inf.dir}/web.xml" overwrite="true"/> <copy file="${configuration}/log4j.properties" tofile="${web-inf.dir}/log4j.properties" overwrite="true"/> <delete file="${meta-inf.dir}/context.xml"/> <war destfile="${release.dir}/MyFirstJob.war" basedir="${webroot.dir}" webxml="${web-inf.dir}/web.xml" /> </target> </project>
原文:http://smileyes.blog.51cto.com/6027700/1624343