sbt:未经授权发布到公司Nexus存储库 [英] sbt: publish to corporate Nexus repository unauthorized

查看:75
本文介绍了sbt:未经授权发布到公司Nexus存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

快速解决方案

所需的凭证期望由nexus定义的确切领域.下文介绍了如何找到您已定义的工具,但最确定的是"Sonatype Nexus Repository Manager".像往常一样将其余详细信息添加到凭据中.

The required credential expects the exact realm as defined by nexus. See below how to find the one you have defined, but most certainly is "Sonatype Nexus Repository Manager". Add the rest of the details to the credentials as normal.

c:/data/user/.sbt/.credentials

c:/data/user/.sbt/.credentials

realm=Sonatype Nexus Repository Manager
host=nexus
user=repouser
password=password

build.sbt 凭据+ =凭据(Path.userHome/".sbt"/".credentials")

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

publishTo <<= version { v: String =>
  val nexus = "http://nexus/" 
  if (v.trim.endsWith("SNAPSHOT"))
    Some("snapshots" at nexus + "content/repositories/libs-snapshots")
  else
    Some("releases" at nexus + "content/repositories/libs-releases")
  }

问题

我正在尝试将罐子发布到公司联系回购中.

I'm trying to publish a jar into a corporate nexus repo.

我可以从Maven做到这一点,并且我已经配置了存储库以能够使用Nexus提供内部jar.但是,由于授权,发布失败.

I'm able to do this fine from Maven, and I have configured the repositories to be able to use Nexus to provide internal jars. However, publication fails due to authorization.

> publish
[info] Packaging c:\app\target\scala-2.10\app_2.10-0.1-sources.jar ...
[info] Wrote D:\app\target\scala-2.10\app_2.10-0.1.pom
[info] :: delivering :: com.app#app_2.10;0.1 :: 0.1 :: release :: Tue May 07 18:28:44 BST     2013
[info] Done packaging.
[info]  delivering ivy file to D:\app\target\scala-2.10\ivy-0.1.xml
[info] Packaging D:\app\target\scala-2.10\app_2.10-0.1.jar ...
[info] Done packaging.
[trace] Stack trace suppressed: run last *:publish for the full output.
[error] (*:publish) java.io.IOException: Access to URL http://nexus/content/groups/common/com/app/app_2.10/0.1/app_2.10-0.1.pom was refused by the server: Unauthorized

c:/data/user/.sbt/.credentials

c:/data/user/.sbt/.credentials

realm=X 
host=nexus
user=repouser
password=password

c:/data/user/.sbt/存储库

c:/data/user/.sbt/repositories

 [repositories]
  local
  x-repo: http://nexus/content/groups/common
  typesafe-ivy-releases: http://repo.typesafe.com/typesafe/ivy-releases/,     [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext]   
  sbt-plugin-releases: http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/
  maven-central

app/build.sbt

app/build.sbt

 name := "app"

 organization := "com.app"

 version := "0.1"

 scalaVersion := "2.10.1"

 libraryDependencies ++= Seq(
"org.scalatest" % "scalatest_2.10" % "2.0.M5b" % "test"
 )

 EclipseKeys.withSource := true

 publishMavenStyle := true

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

 publishTo := Some("X Maven Repo" at "http://nexus/content/groups/common")

我的Maven settings.xml

My Maven settings.xml

 <mirrors>
 <mirror>
  <id>x-repo</id>
  <name>X Maven repo</name>
      <url>http://nexus/content/groups/common</url>
  <mirrorOf>*</mirrorOf>
 </mirror>
 </mirrors>

 <servers>
     <server>
       <id>x-repo</id>
       <username>repouser</username>
       <password>password</password>
     </server>
   </servers>

我已经按照官方文档中的说明进行操作,并且其他各种帖子,包括StackOverflow这样的一个或邮件列表,例如.没有工作.我尝试启用额外的日志记录,但未提供更多详细信息.

I have followed instructions from official doc and various other posts, including StackOverflow such this one or mailing list such as this. None worked. I have tried enabling extra logging, but no further details are given.

我可以使用以下命令手动部署到Maven:

I can manually deploy to maven using this command:

 mvn deploy:deploy-file -Durl=http://nexus/content/repositories/libs-snapshots -DrepositoryId=x-repo -DgroupId=com.app -DartifactId=app -Dpackaging=jar -Dversion=0.1-SNAPSHOT -Dfile=D:\app\target\scala-2.10\app_2.10-0.1.jar

尝试使用以下publishTo,也没有运气

Tried using the following publishTo, also without luck

publishTo <<= version { v: String =>
  val nexus = "http://nexus/" 
  if (v.trim.endsWith("SNAPSHOT"))
    Some("snapshots" at nexus + "content/repositories/libs-snapshots")
  else
    Some("releases" at nexus + "content/repositories/libs-releases")
  }

命令运行正常,直到需要对其进行授权为止,此时它们将失败.

The commands run OK until they need to be authorized, at which point they fail.

凭据中的领域,它对应于maven中的服务器存储库ID还是名称?还是不起作用.

The Realm in the credentials, does it correspond to the Server Repository ID in maven or the Name? Either or it doesn't work.

我一直在尝试为常春藤启用更多日志记录,但是无法获取更多详细信息.

I've been trying to enable more logging for Ivy, but couldn't get more details.

设置ivyLoggingLevel:= UpdateLogging.Full

set ivyLoggingLevel := UpdateLogging.Full

因此,应该进一步记录日志:

According to this, there should be further logging:

https://svn.apache.org/repos/asf/ant/ivy/core/tags/2.2.0/src/java/org/apache/ivy/util/url/IvyAuthenticator. Java

我在内部代理后面,因此我需要同时设置HTTP用户和HTTPS用户以及密码.也许是在这里被阻止了?

I'm behind a internal proxy, so i need to set both HTTP user and HTTPS user and password. Perhaps it's here that it's getting blocked?

关于如何提高常春藤采伐水平的任何建议?

any suggestions how to increase the level of ivy logging?

更新

通过使用 sbt-aether-deploy 插件,我有了一些工作,它使用Maven基础结构(旅行车)进行部署.

I've got something to work, by using sbt-aether-deploy plugin, which uses Maven infrastructure (wagon) to deploy.

凭据完全相同.实际上,这个领域似乎并不重要.

Credentials are exactly the same. In fact, the realm didn't seem to matter.

以下是使用的行:

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

publishTo <<= version { v: String =>
  val nexus = "http://nexus/"
    if (v.trim.endsWith("SNAPSHOT"))
    Some("snapshots" at nexus + "content/repositories/libs-snapshots")
  else 
    Some("releases" at nexus + "content/repositories/libs-releases")
}

seq(aetherSettings: _*)

seq(aetherPublishSettings: _*)

代理,常春藤和联系之间不正确.

Something is not right between the proxy, ivy and nexus.

我仍然对使用常春藤的建议感兴趣.

I would still be interested in suggestions to use ivy.

进一步更新:

使用

curl -X POST http://nexusUser:nexusPassword@nexus/content/repositories/libs-snapshots -v

我能够到达服务器.

指定要使用的代理的结果相同(已配置为绕过本地网络,但是某些Java进程(如SBT)似乎需要标头)

Same result specifying the proxy to use (it's configured to bypass for local networks, but some java processes like SBT seem to require the headers)

当未指定nexusUser:nexusPassword时,我得到以下标头:

When nexusUser:nexusPassword were not specificied, i was getting the following header:

WWW-Authenticate:BASIC realm ="Sonatype Nexus Repository Manager"

WWW-Authenticate: BASIC realm="Sonatype Nexus Repository Manager"

实际上就是问题所在,凭据要求Realm的名称是该确切的标头,而不是像maven定义的其他自定义存储库名称.

effectively that was the issue, the credentials required the name of the Realm to be that exact header, as opposed to other custom repository name like maven defines.

非常感谢!

推荐答案

Ivy使用WWW-Authenticate标头的域,该标头必须逐字节匹配等于凭据文件中配置的字节.

Ivy uses the realm of the WWW-Authenticate header, which will have to match byte-for-byte equal to the one configured in your credentials file.

sbt-aether-deploy使用相同的标头,但使用Aether作为其部署机制.常春藤没有.

sbt-aether-deploy uses the same header, but uses Aether as its deployment mechanism. Ivy does not.

弄清楚WWW-Authenticate标头的值的最简单方法是使用cURL.

The easiest way of figuring out the value of the WWW-Authenticate header is by using cURL.

curl -X POST http://nexus/content/repositories/libs-snapshots -v > /dev/null

cURL将提示您输入用户并通过.

cURL will prompt you for a user and pass.

-v将添加详细信息,因此您将能够看到请求和响应的标题.

-v will add verbosity so you will be able to see the headers of the request and response.

这篇关于sbt:未经授权发布到公司Nexus存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆