使用 svnant 无需用户名或密码
我已经使用命令行 SVN 检查了代码。 我有一个想要运行的 Ant 构建脚本,该脚本将在完成后进行提交。
我想使用 svnant,例如
<svn svnkit="false" javahl="false" failonerror="true">
<commit dir="${dir}" message="${message}"/>
</svn>
但它不起作用并给出此错误
[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 !
但是,如果我直接执行 exec,像这样
<exec executable="svn">
<arg line="commit ${dir} -m '${message}'"/>
</exec>
它将工作正常。 奇怪的是,使用 svnkit="false" 和 javahl="false" 应该使 svnant 使用命令行 svn。
那么这是怎么回事呢? 我不必在 svnant 调用中指定用户名/密码,因为命令行 svn 显然不需要它(它已被缓存)。
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).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简单、可靠的解决方案是将您想要的 svn 用户名和密码存储在您的主目录中的 build.properties 文件中,设置权限以便其他用户无法读取它,并将其加载到您的 ant 脚本中。
我依赖于构建脚本中的身份验证缓存,这很烦人,因为身份验证迟早不会被缓存,或者错误的身份验证将被缓存,当您试图意识到问题所在时,您会浪费时间。 或者您可能决定在不同的环境(例如构建服务器)中运行 ant,这使得向 svn 的身份验证缓存提供数据变得困难。 最好从文件和程序 ant 加载身份验证信息,以便在该文件丢失时给出明确的消息。
您还可以尝试使用 svnkit 命令行客户端来缓存您的身份验证,并查看通过 ant 使用时是否仍然有效。
该帖子讨论了相同的问题: http://www.nabble.com/ svnant-and-authentication-td17865407.html
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