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

查看:34
本文介绍了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")
  }

问题

我正在尝试将一个 jar 发布到公司关系存储库中.

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	argetscala-2.10app_2.10-0.1-sources.jar ...
[info] Wrote D:app	argetscala-2.10app_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	argetscala-2.10ivy-0.1.xml
[info] Packaging D:app	argetscala-2.10app_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/repositories

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,例如 one 或邮件列表,例如 this.没有工作.我已尝试启用额外的日志记录,但未提供更多详细信息.

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	argetscala-2.10app_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.

凭证中的Realm,是对应maven中的Server Repository ID还是Name?要么不行,要么不行.

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

我一直在尝试为 Ivy 启用更多日志记录,但无法获得更多详细信息.

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.爪哇

我在内部代理后面,所以我需要设置 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?

对如何提高 ivy 日志记录有什么建议吗?

any suggestions how to increase the level of ivy logging?

更新

我有一些工作要做,通过使用 sbt-aether-deploy 插件,它使用 Maven 基础架构(wagon)来部署.

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: _*)

代理、ivy 和 nexus 之间有些问题.

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

我仍然会对使用 ivy 的建议感兴趣.

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"

实际上这就是问题所在,凭据要求领域的名称是准确的标头,而不是像 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天全站免登陆