使用curl:500服务器错误将工件包上载到sonatype

使用curl:500服务器错误将工件包上载到sonatype,curl,nexus,sonatype,Curl,Nexus,Sonatype,我想使用curl命令将工件包(jar)上载到: curl \ --verbose \ --user $SONATYPE_USER:$SONATYPE_PASSWORD \ --form "file=$BUNDLE" \ https://oss.sonatype.org/service/local/staging/bundle_upload 该命令基于这样的答案:,我只是习惯于以长格式(--foobar)编写所有选项,以提高shell脚本的可读性。这个问题不是重复

我想使用
curl
命令将工件包(jar)上载到:

curl \
    --verbose \
    --user $SONATYPE_USER:$SONATYPE_PASSWORD \
    --form "file=$BUNDLE" \
    https://oss.sonatype.org/service/local/staging/bundle_upload
该命令基于这样的答案:,我只是习惯于以长格式(
--foobar
)编写所有选项,以提高shell脚本的可读性。这个问题不是重复的,因为a)这里给出的答案对我不起作用B)我有另一个错误,而不是OP of

我得到这个输出:

*   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>
另请参阅,以了解我不使用
--请求发布的原因

我需要在
curl
命令中更改什么


注意:bundle jar文件包含所有文件,如pom等。我可以通过UI上传相同的bundle。

解决方案:在文件名前面添加一个
@
,因此
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/**********"]}
(身份验证输出被截断)
您可以尝试使用
--request POST
选项吗?相同的输出,在第一行添加此选项:注意:
不必要使用-X或--request,帖子已经被推断出来。
另请参见daniel.haxx.se/blog/2015/09/11/uncertible-use-of-curl-x为什么不需要
--request
。为什么@important?因为官方文档中有这样的说明:如果你想知道原因,请咨询Sonatype技术支持。
(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/**********"]}