環境:html
JDK 1.7java
SVNkit 1.8.10windows
Jenkins 1.5.77.svn
背景:ui
在windows slave上須要經過ant腳本從 svn checkout代碼,使用svnant連接不上,報timeout。因此使用另一種方式,用svnkit-cli。url
準備工做:spa
須要將svnkit 1.8.10 release的jar包所有加載到classpath裏(svnkit.jar, svnkit-cli.jar,svnkit-osgi-1.8.10.jar,svnkit-javahl16-1.8.10.jar以及從svnkit-dav-1.8.10.war中lib下的jar包)。code
<path id="path.svnant">component
<fileset dir="D:\Jenkins\tools\svnkit_1.8.0\lib">htm
<include name="*.jar" />
</fileset>
</path>
示例代碼:
<target name="checkout_code">
<echo message="component svn commit..." />
<echo message="username = ${build_svn_userid}" />
<echo message="pasword = ${build_svn_password}" />
<echo message="resopsitory = ${repository_url}/${build_component_path}" />
<delete dir="${workspace.dir}/output/rfview" failonerror="falses" />
<echo message="checkout svn branch from HEAD" />
<java classname="org.tmatesoft.svn.cli.SVN" dir="${workspace.dir}/output/" fork="true">
<arg value="co" />
<arg value="--username" />
<arg value="${svn_userid}" />
<arg value="--password" />
<arg value="${svn_password}" />
<arg value="${repository_url}/${build_component_path}" />
<classpath refid="path.svnkit" />
</java>
</target>
<target name="commit_changes">
<echo message="begin to commit changes...." />
<java classname="org.tmatesoft.svn.cli.SVN" fork="true">
<arg value="commit" />
<arg value="--username" />
<arg value="${svn_userid}" />
<arg value="--password" />
<arg value="${svn_password}" />
<arg value="-m" />
<arg value='"commit message"' />
<arg value="${YOUR WOKING COPY DIR}" />---注意,這裏應該是本地要提交的文件夾路徑。
<classpath refid="path.svnkit" />
</java>
<echo message="component svn commit done." />
</target>
參考svnkit官網:http://www.svnkit.com/documentation.html