Friday, July 31, 2015

SVN copy task causing duplicate path?

There is a problem with the <copy> task after deployed to build server. The path will become duplicate when it is executing causing the path, unable to be retrieve:
   ...

   [svn] svn: File not found: revision 1768, path '/trunk/MessageFlow/trunk/MessageFlow'

   ...
Notice that the path has been duplicated. Here is the existing ANT source:
   ...
   <typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="classpath"/>

   ...

   
      <copy srcUrl="${svnTrunkRoot}/MessageFlow}" destUrl="${svnTagsRoot}/MessageFlow/${newtagname}" message="Tagged by Jenkins."/>
   
As from my study, this is a known error for SVN version 1.7 and above. Luckily opticyclic has developed a new ANT clone which can get rid of this problem. Grab the piece and build it from source. The output will have this, svntask-1.1.1.jar. When deploy to build server, sequence-library-1.0.2.jar, sqljet-1.1.10.jar, svnkit-1.8.5.jar are also needed. There are gang of four, no one left behind.

Without messing up with the existing svn task, I create another task named svn2.
   <path id="svn2.classpath">
      <pathelement location="svntask-1.1.1.jar">
      <fileset dir= "../lib">
         <include name= "*.jar"/>
      </fileset>
   </path>

   <taskdef name="svn2" classname="com.googlecode.svntask.SvnTask" classpathref="svn2.classpath"/>
To use the new copy task command, do this:
   ...
   <svn2 username="admin" password="admin">
      <copy failOnDstExists="true" move="false"
            src="${svnTrunkRoot}/MessageFlow"
            dst="${svnTagsRoot}/MessageFlow/${newtagname}"
            commitMessage="Tagged by Jenkins."/>
   </svn2>
Do take note that the new svn2 doesn't support refid attribute, thus username and password are require whenever svn2 command is invoke.

Last note, this is last minute finding, antlr-runtime-3.4.jar may also needed as I deployed to build server. Otherwise an run-time error will be thrown.

No comments: