Artifactory:使用 cURL 通过 API 将工件从一个存储库复制到另一个存储库

问题描述 投票:0回答:1

使用“复制项目”文档,我尝试将文件从一个工件存储库复制到另一个。但是,每次尝试都会导致 400 Bad Request 返回(并且 API 没有 JSON 响应)。我可以使用 GET 请求通过 API 获取有关 Artifactory 服务器的信息,当登录到 Web UI 时,我可以手动执行相同的文件复制。所以我假设,鉴于 400 返回码,我只是错误地构建了我的 cURL 命令。

这是我的 cURL 命令(

-v

用于获取详细输出):

curl -s \
    -X POST \
    --user "${ARTIFACTORY_USER}:${ARTIFACTORY_API_KEY}" \
    -d "to=prod-deb/${pkg_path}" \
    -d "dry=1" \
    -G "${ARTIFACTORY_API_URL}/copy/testing-deb/${pkg_path}" -v

由于 API 文档指定使用查询字符串格式化请求,因此使用 
-G

以详细输出运行此命令的结果是:

* Trying <REDACTED>:443... * TCP_NODELAY set * Connected to artifactory.mydomain.com (<REDACTED>) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/ssl/certs/ca-certificates.crt CApath: /etc/ssl/certs * TLSv1.3 (OUT), TLS handshake, Client hello (1): * TLSv1.3 (IN), TLS handshake, Server hello (2): * TLSv1.2 (IN), TLS handshake, Certificate (11): * TLSv1.2 (IN), TLS handshake, Server key exchange (12): * TLSv1.2 (IN), TLS handshake, Server finished (14): * TLSv1.2 (OUT), TLS handshake, Client key exchange (16): * TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1): * TLSv1.2 (OUT), TLS handshake, Finished (20): * TLSv1.2 (IN), TLS handshake, Finished (20): * SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384 * ALPN, server accepted to use http/1.1 <snip> cert info </snip> * Server auth using Basic with user 'myuser' > POST /artifactory/api/copy/testing-deb/path/to/pkg.deb?to=/prod-deb/path/to/pkg.deb&dry=1 HTTP/1.1 > Host: artifactory.mydomain.com > Authorization: Basic <REDACTED> > User-Agent: curl/7.68.0 > Accept: */* > * Mark bundle as not supporting multiuse < HTTP/1.1 400 Bad Request < Date: Thu, 29 Feb 2024 18:26:06 GMT < Transfer-Encoding: chunked < Connection: keep-alive < * Connection #0 to host artifactory.mydomain.com left intact

不幸的是,文档不是那么好,所以我不确定我做错了什么。

此服务器正在运行 Artifactory Professional,版本 6.23.23。

curl artifactory
1个回答
0
投票

    复制工件:-
  1. >curl -uadmin:'密码'-XPOST "http://ART-URL/artifactory/api/copy/source-repo-name/artifact-name?to=target-repo-name&dry-run=1" - Lvv

  2. 复制文件夹:-
  3. >curl -uadmin:'密码'-XPOST "http://ART-URL/artifactory/api/copy/source-repo-name/folder-name?to=target-repo-name/folder-name&dry-run =1" -Lvv

  4. 上述命令会将工件/文件夹从一个存储库复制到另一个存储库。有关更多详细信息,请参阅我们的官方
文档

© www.soinside.com 2019 - 2024. All rights reserved.