我想使用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上传相同的包。
答案 0 :(得分:0)
解决方案:在文件名前添加@
,以便curl
命令变为:
curl \
--verbose \
--user $SONATYPE_USER:$SONATYPE_PASSWORD \
--form "file=@$BUNDLE" \
https://oss.sonatype.org/service/local/staging/bundle_upload
现在输出:
(authentication output snipped)
< HTTP/1.1 100 Continue
< HTTP/1.1 201 Created
< Content-Type: text/html;charset=UTF-8
< Date: Fri, 27 Apr 2018 08:02:53 GMT
< Server: nginx
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< Content-Length: 85
< Connection: keep-alive
<
* Connection #0 to host oss.sonatype.org left intact
{"repositoryUris":["https://oss.sonatype.org/content/repositories/**********"]}