Question

I have a multi-module SBT project that I am trying to publish to a remote Apache Archiva.

[error] (core/*:publish) java.io.IOException: Access to URL http://XX.XX.XX.XX/repository/development/com/example/core_2.10/1.0.0.SNAPSHOT.304fcd73d72ffe4a05271197902c36b9a59b4922/core_2.10-1.0.0.SNAPSHOT.304fcd73d72ffe4a05271197902c36b9a59b4922.pom was refused by the server: Unauthorized

For my snapshots, I'm appending the Git SHA-1 hash for the commit.

Build.scala

publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := { _ => true },
publishTo := Some("development" at "http://XX.XX.XX.X/repository/development"),
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials_development"), // archiva credentials by repo

I took care to set the realm correctly per posts I've read. I retrieved it by doing:

curl -X POST http://xx.xx.xx.xx/repository/development -v > /dev/null

.credentials_development

realm=Repository Archiva Managed development Repository
host=XX.XX.XX.XX
user=myuser
password=mypassword

In SBT, I run:

compile
assembly
make-pom
package
publish

I can upload artifacts using the user via the web administration.

How should I be doing it so the publishing works? Do I perhaps need to setup credentials via ivysettings.xml?

Was it helpful?

Solution

A comment in this question led me to the answer: sbt: publish to corporate Nexus repository unauthorized

One cannot include the port (my Archiva server is running on port 8080) on the hostname in the credentials file. It will prevent your credentials from being used during the publish.

I also specified the realm in my publishTo and moved my credential file to ~/.sbt per barnesjd's comment (though not in plugins, just in ~./sbt).

For reference to others, here is my configuration:

Build.scala

publishTo := Some("Repository Archiva Managed development Repository" at "http://XX.XX.XX.XX:8080/respository/development/"),
credentials += Credentials(Path.userHome / ".sbt" / ".archiva_credentials")

.archiva_credentials

realm=Repository Archiva Managed development Repository
host=XX.XX.XX.XX
user=myuser
password=mypassword

OTHER TIPS

I publish to archiva via sbt at work without problems. I recall having a similar frustrating problem, and it was because I had the realm wrong. Assuming you have that correct, the only thing I see different is I specify my credentials in ~/.sbt/0.13/plugins/credentials.sbt. Create such a file, add the following contents:

credentials ++= Seq(
  Credentials("Repository Archiva Managed development Repository",
              "XX.XX.XX.XX", 
              "myuser",
              "mypassword")
)

Note that on the xx.xx.xx.xx section you only put the IP/DNS address of your server. Not the full path.

You may need to remove your current credentials setting to avoid conflicts.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top