【问题标题】:Sonatype Nexus adding Proxy Repository with REST APISonatype Nexus 使用 REST API 添加代理存储库
【发布时间】:2014-10-05 07:09:28
【问题描述】:

我正在尝试使用 REST API 和 curl 将代理存储库添加到我的本地 Sonatype Nexus™ OSS 2.8.1-01,但它不起作用

卷曲命令:

 curl -i -H "Accept: application/xml" -H "Content-Type: application/xml" -f -X POST  -v -d "@/tmp/input.xml" -u
 "admin:admin123" "http://localhost:8081/nexus/service/local/repositories"

直到它工作正常,当我将添加在 input.xml 中定义的托管存储库时,而不是使用代理存储库

使用代理存储库,我会得到以下响应:

 upload completely sent off: 445 out of 445 bytes
 The requested URL returned error: 400 Bad Request
 Closing connection 0

Nexus 日志文件:

2014-08-12 09:57:44,189+0200 TRACE [qtp531741605-42] admin com.thoughtworks.xstream.whitelist.TypeWhitelist - All types allowed: remoteUri
2014-08-12 09:57:44,201+0200 WARN  [qtp531741605-42] admin org.sonatype.nexus.rest.NexusRestletResource - Invalid XML, unable to parse using XStream class org.sonatype.nexus.rest.repositories.RepositoryListPlexusResource
com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$UnknownFieldException: No such field org.sonatype.nexus.rest.model.RepositoryProxyResource.remoteUri

---- Debugging information ----
field               : remoteUri
class               : org.sonatype.nexus.rest.model.RepositoryBaseResource
required-type       : org.sonatype.nexus.rest.model.RepositoryBaseResource
converter-type      : org.sonatype.nexus.rest.repositories.RepositoryBaseResourceConverter
path                : /repository/data/remoteUri
line number         : 1
class[1]            : org.sonatype.nexus.rest.model.RepositoryResourceResponse
converter-type[1]   : org.sonatype.nexus.rest.repositories.RepositoryResourceResponseConverter
version             : 1.4.6-SONATYPE-03

他将remotUri识别为未知字段,但它是配置新代理存储库的必填字段

input.xml:

<?xml version="1.0" encoding="UTF-8"?>
<repository>
  <data>
    <id>maven.jenkins-ci.org</id>
    <name>Jenkins CI</name>
    <repoType>proxy</repoType>
    <repoPolicy>RELEASE</repoPolicy>
    <provider>maven2</provider>
    <providerRole>org.sonatype.nexus.proxy.repository.Repository</providerRole>
    <format>maven2</format>
    <exposed>true</exposed>
    <remoteUri>http://repo.jenkins-ci.org/public/</remoteUri>
  </data>
</repository>

为了防止出现类型不允许的错误,我放了

com.thoughtworks.xstream.whitelist.TypeWhitelist.allowAll=true

在 nexus.properties 中

我做错了什么? 希望有人可以帮助我

问候亚历克斯

【问题讨论】:

    标签: curl proxy repository nexus


    【解决方案1】:

    我建议使用 JSON 而不是 XML 作为有效负载类型。如果您这样做,您可以在创建存储库时观察从 UI 到服务器的 HTTP 流量,UI 会调用您需要的 REST API。

    查看这里了解更多信息:

    http://blog.sonatype.com/2012/07/learning-the-nexus-rest-api-read-the-docs-or-fire-up-a-browser

    【讨论】:

      猜你喜欢
      • 2011-06-14
      • 2013-08-02
      • 1970-01-01
      • 1970-01-01
      • 2021-04-11
      • 2013-06-05
      • 2016-02-19
      • 2014-12-15
      • 1970-01-01
      相关资源
      最近更新 更多