【发布时间】:2018-10-06 03:00:10
【问题描述】:
我想使用curl 命令将工件包(jar)上传到https://oss.sonatype.org:
curl \
--verbose \
--user $SONATYPE_USER:$SONATYPE_PASSWORD \
--form "file=$BUNDLE" \
https://oss.sonatype.org/service/local/staging/bundle_upload
该命令基于此 SO 答案:https://stackoverflow.com/a/47460712/766786,我只是习惯于以长格式 (--foobar) 编写所有选项,以提高 shell 脚本的可读性。这个问题不是重复的,因为 A)那里给定的答案对我不起作用 B)我有另一个错误,而不是 Upload artifact bundle to sonatype 的 OP。
我得到这个输出:
* Trying 54.173.252.242...
* TCP_NODELAY set
* Connected to oss.sonatype.org (54.173.252.242) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (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, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
* subject: OU=Domain Control Validated; CN=*.sonatype.org
* start date: Sep 18 15:02:41 2015 GMT
* expire date: Sep 24 18:39:12 2018 GMT
* subjectAltName: host "oss.sonatype.org" matched cert's "*.sonatype.org"
* issuer: C=US; ST=Arizona; L=Scottsdale; O=GoDaddy.com, Inc.; OU=http://certs.godaddy.com/repository/; CN=Go Daddy Secure Certificate Authority - G2
* SSL certificate verify ok.
* Server auth using Basic with user '**********'
> POST /service/local/staging/bundle_upload HTTP/1.1
> Host: oss.sonatype.org
> Authorization: Basic ********************
> User-Agent: curl/7.55.1
> Accept: */*
> Content-Length: 157
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=------------------------8790eb977ecbbb15
>
< HTTP/1.1 100 Continue
< HTTP/1.1 500 Server Error
< Content-Type: text/html;charset=ISO-8859-1
< Date: Wed, 25 Apr 2018 14:56:07 GMT
< Server: nginx
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< Content-Length: 134
< Connection: keep-alive
* HTTP error before end of send, stop sending
<
* Closing connection 0
* TLSv1.2 (OUT), TLS alert, Client hello (1):
<html><body><error>The server encountered an unexpected condition which prevented it from fulfilling the request</error></body></html>
当添加 --request POST 选项时,我得到完全相同的输出,并在第一行添加了这个:
Note: Unnecessary use of -X or --request, POST is already inferred.
另请参阅https://daniel.haxx.se/blog/2015/09/11/unnecessary-use-of-curl-x/,了解我不使用--request POST 的原因。
我需要在curl 命令中进行哪些更改?
注意:bundle jar 文件包含 pom 等所有文件。我可以通过 UI 上传相同的 bundle。
【问题讨论】:
-
你可以试试
--request POST选项吗? -
相同的输出,在第一行添加:注意:
Unnecessary use of -X or --request, POST is already inferred.另见 daniel.haxx.se/blog/2015/09/11/unnecessary-use-of-curl- x 为什么不需要--request。