How can I provide SBT credentials to my private Artifactory server from a Windows workstation?

穿精又带淫゛_ 提交于 2019-12-07 08:58:41

问题


I'm using sbt 0.13.13 behind a corporate firewall on a Windows desktop.

We have an Artifactory which seems to be working very well for other build-tools, but I also want to get SBT working, however I'm not even able to make sbt 0.13.x boot!

When I try to boot SBT I get this error from the launcher:

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

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

Actually those URLs do exist - when I hit them with Chrome or Curl and provide credentials I am able to retrieve all the required resources.

When I look at the log I can see what's going on:

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

So it's clear that no credentials (or the wrong credentials are being sent). So I looked at how I've got it set up. I have a credentials file which looks something like this in %USERPROFILE%/.sbt/.credentials

realm=Artifactory Realm
host=artifactory.bigcompany.com
user=USERNAME
password=<my api key>

And I have a "plugin" file located at %USERPROFILE%.sbt\0.13\plugins\credentials.sbt which looks like this:

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

And I'm invoking sbt like this:

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

Looking again at the logs - there's nothing at all which suggests that the credentials.sbt plugin has loaded, which in turn suggests that I've put the file in the wrong location or that there's something else about it that makes it unusable.

So can somebody help me - how do I need to tweak this setup so that it actually works? Is there some missing


回答1:


I think I've encountered the same problem.

Since you've already created a proper credential file under %USERPROFILE%/.sbt/.credentials, you might need to set a system or user environment variable:

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



来源:https://stackoverflow.com/questions/41299355/how-can-i-provide-sbt-credentials-to-my-private-artifactory-server-from-a-window

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