使用curl将工件捆绑包上传到声呐:500服务器错误 [英] Upload artifact bundle to sonatype using curl: 500 Server Error

查看:180
本文介绍了使用curl将工件捆绑包上传到声呐:500服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过以下方式将工件捆绑包(jar)上传到 https://oss.sonatype.org curl命令:

I want to upload an artifact bundle (jar) to https://oss.sonatype.org with the curl command:

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)我有一个错误,而不是

The command was based on this SO answer: https://stackoverflow.com/a/47460712/766786, I just have the habit of writing all options in their long form (--foobar) for better readability in shell scripts. This question is not a duplicate, because A) the given answer there doesn't work for me B) I have another error than the OP of 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选项时,我得到的输出完全相同,并将其添加为第一行:

When adding the --request POST option, I get exactly the same output, with the addition of this as the first line:

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.

See also https://daniel.haxx.se/blog/2015/09/11/unnecessary-use-of-curl-x/ for the reason why I don't use --request POST.

我需要在curl命令中进行哪些更改?

What do I need to change in my curl command?

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

Note: The bundle jar file contains all files like pom etc. I am able to upload the same bundle via UI.

推荐答案

解决方案:在文件名前面添加@,因此curl命令变为:

Solution: add an @ in front of the filename, so the curl command becomes:

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/**********"]}

这篇关于使用curl将工件捆绑包上传到声呐:500服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆