tags:

views:

831

answers:

1

I have checked out code using command-line SVN. I have an Ant build script that I want to run that will do a commit when its done.

I'd like to use svnant, such as

<svn svnkit="false" javahl="false" failonerror="true">
    <commit dir="${dir}" message="${message}"/>
</svn>

but its not working and giving this error

[svn] <Commit> started ...
[svn] svn: Commit failed (details follow):
[svn] svn: OPTIONS of 'http://svn.local/path/to/my/proj': authorization failed (http://svn.local)
[svn] <Commit> failed !

However, if I do an exec directly, like this

<exec executable="svn">
    <arg line="commit ${dir} -m '${message}'"/>
</exec>

it will work fine. What's odd is that using svnkit="false" and javahl="false" is supposed to make svnant use the command line svn.

So what's going on here? I shouldn't have to specify the username/password in the svnant call, as command-line svn clearly doesn't need it (its been cached).

+1  A: 

The simple, reliable solution is to store your desired svn username and password in a build.properties file in your home directory, set permissions so no other users can read it, and load that in your ant script.

I've relied on auth caching in build scripts and it's annoying because sooner or later the authentication won't be cached, or the wrong authentication will be cached, and you will waste time while you try to realize what's wrong. Or you might decide to run ant in a different environment, like a build server, that makes it difficult to feed svn's authentication cache. It's better to load your authentication information from a file and program ant to give a clear message when that file is missing.

You could also try using the svnkit command line client to cache your authentication and see whether that still works when used via ant.

This thread talks about the same issues: http://www.nabble.com/svnant-and-authentication-td17865407.html

joeforker