【问题标题】:Error deploying artifact: Failed to transfer file Return code is: 401部署工件时出错:传输文件失败返回代码为:401
【发布时间】:2014-02-09 16:16:05
【问题描述】:

我正在尝试将我的库 ListBuddies 上传到 maven。为此,我正在使用 @ChrisBanes 的 gradle-mvn-push github 项目。我遵循他在他的 repo 中提到的所有步骤以及在使用该 repo 之前需要的其他一些步骤:

本地 gradle.properties 文件(签名密钥仅在发布时需要,因此对于 SNAPSHOT 应该不是问题):

//These are the username/password that I use for:
//[JIRA](https://issues.sonatype.org) 
//and [NEXUS](https://oss.sonatype.org

NEXUS_USERNAME=jpardogo1
NEXUS_PASSWORD=jira-pass

//This is the key ID that I obtain doing "gpg --list-keys" on the terminal
signing.keyId=my-keyid

//This is the paraphrase I set when I first created the key
signing.password=my-paraphrase

//That's the path to my secret key ring
signing.secretKeyRingFile=/Users/jpardogo/.gnupg/secring.gpg

看起来一切都已正确设置,但当我这样做时:

gradle clean build uploadArchives

最后我收到代码 ERROR 401:

:library:uploadArchives                 
Uploading: com/jpardogo/listbuddies/library/1.0.0-SNAPSHOT/library-1.0.0-20140209.151716-    1.aar to repository remote at https://oss.sonatype.org/content/repositories/snapshots/
Transferring 67K from remote            
:library:uploadArchives FAILED          

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':library:uploadArchives'.
> Could not publish configuration 'archives'
   > Error deploying artifact 'com.jpardogo.listbuddies:library:aar': Error deploying artifact: Failed to transfer file:     https://oss.sonatype.org/content/repositories/snapshots/com/jpardogo/listbuddies/library/1.0.0-SNAPSHOT/library-1.0.0-20140209.151716-1.aar. Return code is: 401

* Try:         
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED   

我昨天和今天一整天都在寻找答案,但我无法解决。错误 401 的原因在 here 中有很好的解释,但我无法解决任何问题,我还读到这可能是由于用户权限问题,尽管我按照 guide 所说的那样在 Jira 上注册。

希望您能帮助我,如果您需要更多信息,请告诉我。谢谢。

编辑:我想用jira ticket 及其 cmets 的链接更新问题。

【问题讨论】:

  • 您是否尝试通过您的凭据登录 Sonatype Nexus? JIRA 和 Nexus 的凭据通常不一样......可能在你的情况下它们是,但首先我会尝试通过浏览器登录......
  • 是的,我做到了,我使用这些凭据(用户名和密码)在 Nexus UI 上登录 oss.sonatype.org/index.html#welcome
  • 您是否在 build.gradle 文件中添加了authentication(userName: mavenUser, password: mavenPassword)
  • 整个项目发布在github(goo.gl/SiD5LR),是开源的。它正在与 gradle-mvn-push 一起使用,并且身份验证行在此处 goo.gl/iuk8dx 上。 gradle-mvn-push 自述文件解释了它的功能。

标签: android maven authentication android-gradle-plugin sonatype


【解决方案1】:

我终于解决了。所有配置都没问题。问题出在文件gradle.properties 上。因为我复制粘贴了文件的结构,所以在 NEXUS_USERNAME 旁边提醒了一个隐藏的表格,所以用户名实际上是与表格一起发送的,我收到了一个身份验证错误。

有时事情比你想象的要简单,而你却看不到它们。下次我要做的第一件事就是检查文件的格式。

【讨论】:

  • 是的,这是一个很棒的解决方案。我已经尝试了一个月的))。
【解决方案2】:

我遇到了完全相同的问题,原因是:我的密码(生成的)包含反斜杠\

解决方案gradle.properties中的反斜杠需要转义!

示例

ossrhPassword=partBeforeBackslash\\\\partAfterBackslash

代替:

ossrhPassword=partBeforeBackslash\partAfterBackslash

【讨论】:

    【解决方案3】:

    对我来说,问题是我正在上传代表中已经存在的版本。解决方案只是更改 build.gradle 文件中的“版本”。

    【讨论】:

      猜你喜欢
      • 2014-01-01
      • 1970-01-01
      • 2015-05-12
      • 1970-01-01
      • 2021-12-11
      • 2016-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多