如何从Windows工作站向我的私有Artifactory服务器提供SBT凭据?

时间:2016-12-23 10:10:47

标签: scala sbt artifactory

我在Windows桌面上的公司防火墙后面使用sbt 0.13.13。

我们有一个Artifactory似乎对其他构建工具非常有效,但我也想让SBT工作,但是我甚至无法使sbt 0.13.x启动!

当我尝试启动SBT时,我从启动器中收到此错误:

C:\workspace\aggregator2>c:\apps\sbt-0.13.13\sbt-launcher-packaging-0.13.13\bin\sbt
Getting org.scala-sbt sbt 0.13.13 ...

:: problems summary ::
:::: WARNINGS
                module not found: org.scala-sbt#sbt;0.13.13

        ==== local: tried

          C:\Users\USERNAME\.ivy2\local\org.scala-sbt\sbt\0.13.13\ivys\ivy.xml

          -- artifact org.scala-sbt#sbt;0.13.13!sbt.jar:

          C:\Users\USERNAME\.ivy2\local\org.scala-sbt\sbt\0.13.13\jars\sbt.jar

        ==== my-ivy-proxy-releases: tried

          http://artifactory.bigcompany.com:8081/artifactory/virtual-sbt/org.scala-sbt/sbt/0.13.13/ivys/ivy.xml

        ==== my-maven-proxy-releases: tried

          http://artifactory.bigcompany.com:8081/artifactory/virtual-sbt/org/scala-sbt/sbt/0.13.13/sbt-0.13.13.pom

          -- artifact org.scala-sbt#sbt;0.13.13!sbt.jar:

          http://artifactory.bigcompany.com:8081/artifactory/virtual-sbt/org/scala-sbt/sbt/0.13.13/sbt-0.13.13.jar

                ::::::::::::::::::::::::::::::::::::::::::::::

                ::          UNRESOLVED DEPENDENCIES         ::

                ::::::::::::::::::::::::::::::::::::::::::::::

                :: org.scala-sbt#sbt;0.13.13: not found

                ::::::::::::::::::::::::::::::::::::::::::::::

实际上这些网址确实存在 - 当我点击Chrome或Curl并提供凭据时,我可以检索所有必需的资源。

当我查看日志时,我可以看到发生了什么:

try to get credentials for: Artifactory Realm@artifactory.bigcompany.com
authentication: k='Artifactory Realm@artifactory.bigcompany.com' c='null'
HTTP response status: 401 url=http://artifactory.bigcompany.com:8081/artifactory/virtual-sbt/org.scala-sbt/sbt/0.13.13/ivys/ivy.xml
CLIENT ERROR: Unauthorized url=http://artifactory.bigcompany.com:8081/artifactory/virtual-sbt/org.scala-sbt/sbt/0.13.13/ivys/ivy.xml
    my-ivy-proxy-releases: resource not reachable for org.scala-sbt#sbt;0.13.13: res=http://artifactory.bigcompany.com:8081/artifactory/virtual-sbt/org.scala-sbt/sbt/0.13.13/ivys/ivy.xml
    my-ivy-proxy-releases: no ivy file found for org.scala-sbt#sbt;0.13.13

所以很明显没有凭证(或者发送了错误的凭证)。所以我看看我是如何设置它的。我有一个凭证文件,在%USERPROFILE%/。sbt / .credentials

中看起来像这样
realm=Artifactory Realm
host=artifactory.bigcompany.com
user=USERNAME
password=<my api key>

我有一个位于%USERPROFILE%.sbt \ 0.13 \ plugins \ credentials.sbt 的“插件”文件,如下所示:

credentials += Credentials(Path.userHome / ".sbt" / ".credentials")

我正在调用这样的:

c:\apps\sbt-0.13.13\sbt-launcher-packaging-0.13.13\bin\sbt

再看一下日志 - 什么都没有表明credentials.sbt插件已经加载,这反过来表明我把文件放在了错误的位置,或者说有其它东西让它无法使用

有人可以帮助我 - 我如何调整此设置以使其真正起作用?是否有一些缺失

1 个答案:

答案 0 :(得分:3)

我想我遇到了同样的问题。

由于您已在%USERPROFILE%/.sbt/.credentials下创建了正确的凭据文件,因此您可能需要设置系统或用户环境变量:

set SBT_CREDENTIALS=%USERPROFILE%/.sbt/.credentials