Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 [email protected]
authentication: k='Artifactory [email protected]' 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

like image 353
Salim Fadhley Avatar asked Dec 23 '16 10:12

Salim Fadhley


1 Answers

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

like image 59
aietcn Avatar answered Nov 05 '22 23:11

aietcn