【问题标题】:how to upload JAR to Nexus OSS 3?如何将 JAR 上传到 Nexus OSS 3?
【发布时间】:2016-11-30 07:35:24
【问题描述】:

如何通过curl Nexus 3 上传 jar? 我尝试使用link tips,但没有成功。

这是我的尝试:

curl -v -F r = -F releases hasPom = true and = -F jar -F file = @. / v12.1.0.1 / pom.xml -F file = @. / v12.1.0.1 / ojdbc7.jar -u admin: admin123 http: // localhost: 8081 / repository / maven releases

curl -v -F r = -F releases hasPom = false -F and -F jar = g = com.oracle.jdbc -F = ojdbc7 -F v = 1.0 p = -F jar -F file = @. / v12 .1.0.1 / ojdbc7.jar -u admin: admin123 http: // localhost: 8081 / repository / maven releases

两者都有 400 Bad Request。

【问题讨论】:

  • 为什么你的参数中有那么多空格?

标签: nexus nexus3


【解决方案1】:

目录内容

cert_for_nexus.pem

curl.exe

pom.xml

utils-1.0.jar

为 http 配置了 Nexus v3

curl -v -u admin:admin123 --upload-file pom.xml http://localhost:8081/nexus/repository/maven-releases/org/foo/utils/1.0/utils-1.0.pom

curl -v -u admin:admin123 --upload-file utils-1.0.jar http://localhost:8081/nexus/repository/maven-releases/org/foo/utils/1.0/utils-1.0.jar

Nexus v3 配置为 https

  • 先决条件:必须启用 curl 并启用 SSL(link - 左侧菜单)

curl -v --cacert cert_for_nexus.pem -u admin:admin123 --upload-file pom.xml https://localhost:8443/nexus/repository/maven-releases/org/foo/utils/1.0/utils-1.0.pom

curl -v --cacert cert_for_nexus.pem -u admin:admin123 --upload-file utils-1.0.jar https://localhost:8443/nexus/repository/maven-releases/org/foo/utils/1.0/utils-1.0.jar

pom.xml 的内容

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.foo</groupId>
  <artifactId>utils</artifactId>
  <version>1</version>
</project>

编辑: 两个 https 示例的固定 -u 顺序

【讨论】:

    【解决方案2】:

    你可以使用nexus-cli

    docker run -ti -v $(pwd):$(pwd):ro sjeandeaux/nexus-cli:0.2.0 \
                              -repo=http://nexus:8081/repository/maven-releases \
                              -user=admin \
                              -password=admin123 \
                              -file=$(pwd)/upload.jar \
                              -groupID=your.group \
                              -artifactID=yourArtifactID \
                              -version=0.1.0 \
                              -hash md5 \
                              -hash sha1
    

    【讨论】:

      【解决方案3】:

      我已将您的代码修改如下。请试试这个。

      curl -v -F r=releases -F hasPom=false -F e=jar -F g=com.oracle.jdbc -F a=ojdbc7 -F v=1.0 -F p=jar -F file=@"./v12.1.0.1/ojdbc7.jar" -u admin:admin123 http://localhost:8081/nexus/service/local/artifact/maven/content
      

      另外我建议使用完整路径而不是相对路径。你能分享你在哪里使用这个 curl sn-p 吗?有像 Jenkins 这样的 CI 工具吗?

      【讨论】:

      • Nexus v3 不支持 URL“service/local/artifact”。
      • @grajsek 你能确认这个休息端点是否已经在 OSS3 中被删除了吗?我会改成一样的。
      • 与 Nexus 2 相比,上传文件的路径发生了变化 - 现在是 /repository/&lt;repo-id&gt;/&lt;full-path-of-file-including-group-and-version&gt;,例如/repository/snapshots/com/foo/bar/1.0.0-SNAPSHOT/baz-1.0.0-SNAPSHOT.pom。详情请见support.sonatype.com/hc/en-us/articles/…
      猜你喜欢
      • 2017-02-24
      • 2013-05-31
      • 1970-01-01
      • 1970-01-01
      • 2017-01-29
      • 2015-07-26
      • 1970-01-01
      • 2017-03-09
      • 1970-01-01
      相关资源
      最近更新 更多