SVN-ANT copy task doesn't work, svn copy from CLI does, same arguments

。_饼干妹妹 提交于 2019-12-10 10:48:14

问题


I am using SVN ANT version 1.3.1, ANT 1.7.1, Java 1.6u, and the SVN repo is 1.6 (I think - the prod\db\format file says "4".)

I have two SVN targets (I wonder if the "commit" task isn't completing before the "copy" task attempts to execute, which is why I will quote it as part of my build.xml.)

I am attempting to tag a release as a production version (seems like a fairly common task for an ANT build relying on SVN-ANT, right?) I can do the following on the command line:

svn copy http://svnserver/svn/prod/Production/App \
     http://svnserver/svn/prod/Archive/App/1.5 \
     -m "Tagging Release of App as Version 1.5"

and I get, of course

Committed revision 27.

However, when I try:

<target name="check-in" >
    <svn refid="svn.settings">
        <commit message="${application.name} - Committed to Prod" > 
            <fileset dir="${src.dir}">
                <include name= "**/*"/>
            </fileset>
        </commit>
    </svn>
</target>

<target name="tag-version-number" depends="check-in" >
    <svn refid="svn.settings">
        <copy
            srcUrl="http://svnserver/svn/prod/Production/App/"
            destUrl="http://svnserver/svn/prod/Archive/App/1.5/"
            message="Tagging Release of App as Version 1.5">
        </copy>
    </svn>
</target>

I'm getting back weird errors:

check-in:

tag-version-number:
      [svn] svn: File not found: revision 28, path '/Production/App/Production/App'
      [svn] svn: '/svn/prod/!svn/bc/28/Production/summons' path not found: 404 Not Found (http://svnserver)
      [svn] svn: File not found: revision 28, path '/Production/App/Production/App'
      [svn] svn: '/svn/prod/!svn/bc/28/Production/summons' path not found: 404 Not Found (http:/svnserver)
      [svn] <Copy> failed.

BUILD FAILED
C:\build\promote_prod.xml:210: Can't copy

They make me think that perhaps the commit is not going through all the way before it attempts to access the path on the SVN repo? If so, what can I do to ensure that it waits for the commit goes through? Everything was committing just fine before I added this new "tag-version-number" target (and, for the record, this is the only time in the build script that target "check-in" is running.)

Is the issue something else?


回答1:


Are you using svn-kit? If so, I ran into the same problem today while trying to get some tried and true build scripts migrated to a new instance of Jenkins at work. When preparing an official release, we tag with the release number and then pull the code based on the tag to build it. Like the OP, I feel like this must be a pretty standard use case.

By the way, run ant with the -v flag and svnant will report whether it's using svnkit, javahl or falling back to the command line:

  [svn] Using svnkit
  [svn] <Export> started ...
  [svn] export -r HEAD https://foo.com/svn/project

As best as I can tell, svnant 1.3.1 (and the version of svnkit that it depends on) simply doesn't work 100% with SVN server 1.7.x. It works fine for us for some commands, including export, but when it came time to tag by using svn copy, we were getting the same error described above:

22:06:48        [svn] copy -rHEAD https://foo.com/svn/project/trunk https://foo.com/svn/project/tags/tag3
22:06:48        [svn] svn: File not found: revision 64, path '/project/trunk/project/trunk'
22:06:48        [svn] svn: '/svn/project/!svn/bc/64/project/trunk' path not found: 404 Not Found (https://foo.com)

Thankfully, a savior was out there by the name of opticylic. Open a new tab in your browser and head on over to:

https://github.com/opticyclic/svntask

Grab svntask-1.7-1.0.9.zip from the Downloads section and follow the installation instructions, largely just a matter of declaring the taskdef with the appropriate classpath. The usage of the task is slightly different from tigris' svnant. Specifically it's

<copy src="url" dst="url2" commitMessage="tmbg"/> 

instead of

<copy srcUrl="url" destUrl="url2" message="flood"/>, 

and the newish svnsettings are no longer supported, so you'll have to specify username and password directly in the tag.

Once this is done, svn copy should work fine, making it possible to apply a tag from ant. N.B. make sure that opticylic's svnant task does not see any of the old svnant libraries during execution time. I previously had the svn-related jars in my ant/lib, so had to remove them in order to use opticyclic's svnant.

Finally, I realized that svn export is unfortunately NOT supported by opticylic's svnant, but we require it for the build I was working on. As such, I was forced to make BOTH svnant's available to my build. As long as you specify both of their classpaths independently and (important!) give one of them a new name, since they both use svn as the tagname by default), you should be able to do the same:

<path id="svnant.classpath">
        <fileset dir="lib/svnant">
          <include name="*.jar"/>
        </fileset>
</path>
<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svnant.classpath"/>

<path id="svnant2.classpath">
            <fileset dir="lib/svn2">
              <include name="*.jar"/>
            </fileset>
</path>
<taskdef name="svn2" classname="com.googlecode.svntask.SvnTask" classpathref="svnant2.classpath"/>

Here, I've allowed tigris' svnant to claim the default 'svn' tag name while giving opticyclic's the tag svn2. In this manner, we can call either in the course of the ant script. Just remember to pay attention that you're using the correct syntax required for the svnant you're using at any given moment.

Perhaps opticyclic will add export to their svnant, now that they have a few new fans. That would allow us to simplify the above and simply use the newer svnant outright.



来源:https://stackoverflow.com/questions/11554564/svn-ant-copy-task-doesnt-work-svn-copy-from-cli-does-same-arguments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!