【问题标题】:How to download artifacts using wget from Sonatype Nexus如何使用来自 Sonatype Nexus 的 wget 下载工件
【发布时间】:2014-06-29 01:28:39
【问题描述】:

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

有谁知道,如何让它工作?

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

【问题讨论】:

    标签: linux wget nexus sonatype


    【解决方案1】:

    该 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 以使下载的文件名正确。请参阅此处了解更多信息:

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

    【讨论】:

    • powershell 有吗?我在 ps 上得到了这个,Invoke-WebRequest:找不到接受参数“--password=admin123”的位置参数。这是命令: wget --user=admin --password=admin123 "ec2-54-299-XX-231.us-west-2.compute.amazonaws.com:8081/nexus/service/local/artifact/maven/content?g=org&a=foo&v=1.0&r=releases"跨度>
    【解决方案2】:

    对于联结 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

    repository id = Sample_Replatform_Stage_2_Release(您将其视为 repo 的名称)

    命令将是

     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-

    【讨论】:

      【解决方案3】:

      GNU Wget 1.20.3 建立在 darwin19.0.0 之上。是这样的:

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

      【讨论】:

        猜你喜欢
        • 2022-01-01
        • 1970-01-01
        • 2016-11-01
        • 1970-01-01
        • 2016-08-03
        • 2015-02-14
        • 2013-05-07
        • 2018-01-14
        • 2018-09-12
        相关资源
        最近更新 更多