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

2024-03-16

我想上传一个工件包(jar)到https://oss.sonatype.org https://oss.sonatype.orgcurl命令:

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 https://stackoverflow.com/a/47460712/766786,我只是习惯以长形式写出所有选项(--foobar) 以提高 shell 脚本的可读性。这个问题不是重复的,因为A)给出的答案对我不起作用B)我有另一个错误而不是OP将工件包上传到 sonatype https://stackoverflow.com/questions/47436227/upload-artifact-bundle-to-sonatype.

我得到这个输出:

*   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/ https://daniel.haxx.se/blog/2015/09/11/unnecessary-use-of-curl-x/因为我不使用的原因--request POST.

我需要改变什么curl命令?

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


解决办法:添加一个@在文件名前面,所以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/**********"]}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用curl将工件包上传到sonatype:500服务器错误 的相关文章

随机推荐