问题描述
我正在尝试在公司防火墙后面运行 SBT.另一个团队配置了一个 Artifactory 代理.这个代理在匿名访问开启的情况下工作正常,但是当我们让它需要密码时,我们认为开始出错了.
I'm trying to run SBT behind a corporate firewall. Another team has configured an Artifactory proxy. This proxy works fine with anonymous access switched on, but when we make it require a password thinks start to go wrong.
当我在工作站上运行 SBT 时,出现以下错误:
When I run SBT on my workstation I get the following error:
[error] Unable to find credentials for [Artifactory Realm @ coderepo.xxx.amrs.bigco.com]
这样做的结果是我无法引导 sbt:
The result of this is that I cannot bootstrap sbt:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.scala-lang#scala-library;2.10.6: not found
[warn] :: org.scala-sbt#sbt;0.13.12: not found
[warn] :: org.scala-lang#scala-compiler;2.10.6: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
我尝试将 .credentials 文件放入 ~/.sbt 和 ~/.ivy2:我一直在测试以下变体,但所有这些都不起作用:
I've tried putting a .credentials file in ~/.sbt and also ~/.ivy2: I have been testing variations on the following, all of which do not work:
realm=Artifactory Realm @ coderepo.xxx.amrs.bigco.com
host=coderepo.xxx.amrs.bigco.com
user=<username>
password=<pwd>
我猜这个错误意味着它无法找到与领域匹配的凭据定义,所以我在两个位置尝试了第一行的多个版本:
I'm guessing that this error means that it was unable to locate a credentials definition that matched the realm, so I tried a number of versions of the first line in both locations:
realm=Artifactory Realm
realm=[Artifactory Realm @ coderepo.xxx.amrs.bigco.com]
realm=coderepo.xxx.amrs.bigco.com
似乎没有任何影响.
那么允许 SBT 使用用户名和身份验证的正确方法是什么?密码保护的 Artifactory 存储库的密码?
So what is the correct way to allow SBT to authenticate with username & password to a password protected Artifactory repository?
UPDATE0:根据 Ivy 文档,最有可能的领域名称就是Artifactory Realm".根据 SBT 文档,凭据文件的正确默认位置应该是 %USERPROFILE%/.sbt/.credentials(是的,我使用的是 Windows).即使删除了我的 .ivy2 目录中的 .credentials 文件,它仍然不起作用.
UPDATE0: According to the Ivy documentation, the most likely realm name is simply "Artifactory Realm". According to the SBT documentation, the correct default location of the credentials file should be %USERPROFILE%/.sbt/.credentials (yes, I'm using Windows). Even after deleting the .credentials file in my .ivy2 directory it still doesn't work.
UPDATE1:相关但实际上没有帮助:
UPDATE1: Relevant but not actually helpful:
UPDATE2:我开始怀疑这是 sbt 中的错误 - 我在这里添加了一个问题:https://github.com/sbt/sbt/issues/2817
UPDATE2: I'm starting to suspect that this is a bug in sbt - I've added an issue here: https://github.com/sbt/sbt/issues/2817
推荐答案
参见 此问题 了解有关如何配置全局凭据的详细信息.
See this question for details on how to configure global credentials.
总结:
如果您需要从代理存储库启动 SBT,请将系统属性 sbt.boot.credentials
设置为指向您的凭据文件.您可以在 %CSIDL_PROGRAM_FILESX86%/sbt/conf/sbtconfig.txt
中执行此操作,例如:
If you need to boot SBT from a proxy repository, set the system property sbt.boot.credentials
to point to your credentials file. You can do this in your %CSIDL_PROGRAM_FILESX86%/sbt/conf/sbtconfig.txt
, for example:
-Dsbt.boot.credentials=/Users/my-user-name/.sbt/credentials
或者,您可以将 SBT_CREDENTIALS
环境变量用于相同目的.
Alternatively you can use the SBT_CREDENTIALS
environment variable for the same purpose.
对于 Artifactory,credentials
文件中的领域应设置为:
For Artifactory, the realm in the credentials
file should be set to:
realm=Artifactory Realm
为了对依赖项检索进行身份验证,请使用 credentials
设置创建一个类似 %USERPROFILE%/.sbt/0.13/plugins/my-credentials.sbt
的文件.例如:
For authenticating dependency artifact retrieval, create a file like %USERPROFILE%/.sbt/0.13/plugins/my-credentials.sbt
with a credentials
setting. For example:
credentials += Credentials(Path.userHome / ".sbt" / "credentials")
这篇关于尝试从 Artifactory 虚拟存储库下载时,SBT 无法找到凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!