通过REST API接口上传Nexus仓库

一、Nexus API文档

API文档链接:Components API

通过REST API接口上传Nexus仓库_第1张图片

二、上传API接口说明

在Nexus中可以直接调试api接口,url参考:http://localhost:8081/#admin/system/api

通过REST API接口上传Nexus仓库_第2张图片

通过REST API接口上传Nexus仓库_第3张图片

三、上传请求案例 

$ curl -X POST "http://localhost:8081/service/rest/v1/components?repository=maven-release"  -H "accept: application/json"  -H "Content-Type: multipart/form-data"  -F "maven2.groupId=com.android.test"  -F "maven2.artifactId=test"  -F "maven2.version=1.0.0"  -F "maven2.packaging=jar"  -F "[email protected]"  -F "maven2.asset1.extension=android-support-v4.jar"  -u yangxiaoyang:12345
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0 1260k    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

四、问题

通过API上传只能上传release版本,不能上传snapshot版本,在Nexus页面上上传也有这个限制

$ curl -X POST "http://localhost:8081/service/rest/v1/components?repository=maven-snapshots"  -H "accept: application/json"  -H "Content-Type: multipart/form-data"  -F "maven2.groupId=com.android.test"  -F "maven2.artifactId=test"  -F "maven2.version=1.0.0-SNAPSHOT"  -F "maven2.packaging=jar"  -F "[email protected]"  -F "maven2.asset1.extension=android-support-v4-SNAPSHOT.jar"  -u yangxiaoyang:12345
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1260k  100   109  100 1260k    109  1260k  0:00:01 --:--:--  0:00:01 2239k[ {
  "id" : "*",
  "message" : "Upload to snapshot repositories not supported, use the maven client."
} ]

你可能感兴趣的:(可持续集成,Maven,nexus,仓库,api上传)