[英]Deploy Maven artifacts on Sonatype Nexus repository hosted on Linux
[英]How to download artifacts using wget from Sonatype Nexus
我启动并运行了一个 Sonatype Nexus 实例,需要编写一个脚本来手动下载特定的工件。
我尝试使用 REST API 和 wget:
wget --user=username --password=password http://<ip>:<port>/nexus/service/local/artifact/maven/content?g=<group>&a=<artifact>&v=<version>&r=snapshots
Resolving <ip stuff>
Connecting to <ipv6 stuff>... failed: Connection refused.
Connecting to <ipv4 stuff>... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Reusing existing connection to <ip>:<port>.
HTTP request sent, awaiting response... 400 Bad Request
2014-05-11 20:17:01 ERROR 400: Bad Request.
有谁知道,如何让这个工作?
编辑:我可以使用我的浏览器下载工件(并登录到网络界面)
URL 看起来是正确的,但您必须引用它,因为它包含特殊字符。
wget --user=username --password=password "http://<ip>:<port>/nexus/service/local/artifact/maven/content?g=<group>&a=<artifact>&v=<version>&r=snapshots"
您可能还想添加--content-disposition
以使下载的文件名正确。 浏览此处获取更多信息:
对于联系 3
wget --user=userid --password=password 'https://nexusurl:8081/nexus/repository/<repository id>/<replace the grouf is . with />/<artifact id>/<version>/<file name>' -O ${WORKSPACE}/<new file name>
例子
组 ID =com.sap.cloudfoundry.mta_plugin_linux
工件 id =com.sap.cloudfoundry.mta_plugin_linux.api
联系网址 = alm.xxxxxx.com
$WORKSPACE=jenkins 当前工作区
新文件名=cf-cli-mta-plugin-2.0.3-linux-x86_64.bin
存储库 id = Sample_Replatform_Stage_2_Release(这是您看到的存储库名称)
该命令将是
wget --user=USERID --password=PASSWORD 'https://alm.xxxxxxx.com/nexus/repository/sample_Replatform_Stage_2_Release/com/sap/cloudfoundry/mta_plugin_linux/com.sap.cloudfoundry.mta_plugin_linux.api/2.0.3/com.sap.cloudfoundry.mta_plugin_linux.api-2.0.3.bin' -O ${WORKSPACE}/cf-cli-mta-plugin-2.0.3-linux-x86_64.bin
最重要的是,对于 nexus rest api,artifactID-version 应始终与文件名匹配,否则您将收到 maven2 存储库格式错误
有关其他参数和格式,您可以查看https://support.sonatype.com/hc/en-us/articles/213465488-How-can-I-retrieve-a-snapshot-if-I-don-t-know -确切的文件名-
基于 darwin19.0.0 的 GNU Wget 1.20.3。 是这样的:
wget --http-user myusername --http-password=mypassword https://nexus.example.com/myfile.zip
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.