如何使用Sonatype Nexus的wget下载工件

时间:2014-05-11 18:19:20

标签: linux wget nexus sonatype

我启动并运行了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.

有谁知道,如何让它发挥作用?

编辑:我可以使用我的浏览器下载工件(并登录到网络界面)

3 个答案:

答案 0 :(得分:24)

网址看起来是正确的,但您必须引用它,因为它包含特殊字符。

wget --user=username --password=password "http://<ip>:<port>/nexus/service/local/artifact/maven/content?g=<group>&a=<artifact>&v=<version>&r=snapshots"

您还可能需要添加--content-disposition,以便下载的文件名正确无误。有关更多信息,请参见此处:

https://support.sonatype.com/entries/23674267

答案 1 :(得分:1)

nexus 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

nexus url = alm.xxxxxx.com

$ WORKSPACE = jenkins当前工作空间

new filename = 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-the-exact-filename-

中查看

答案 2 :(得分:0)

基于darwin19.0.0构建的GNU Wget 1.20.3。像这样:

wget --http-user myusername --http-password=mypassword https://nexus.example.com/myfile.zip
相关问题