使用curl发布到Artifactory不起作用

时间:2015-06-01 15:14:05

标签: curl publish artifactory

我有一个(Gradle-built)项目,它在<projectRoot>/build/libs/myapp-<version>.jar生成一个JAR。我现在正在尝试编写一个curl命令,将JAR发布到Artifactory,如下所示:

curl -i -X PUT -u myuser:12345@$ -T "build/libs/myapp-0.1.20.jar" "http://artifactory.example.com/libs-release-local/com/me/myapp/myapp/0.1.20/myapp-0.1.20.jar"

当我在控制台中运行时,我得到:

HTTP/1.1 100 Continue

HTTP/1.1 403 Forbidden
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=utf-8
Content-Language: en
Content-Length: 961
Date: Mon, 01 Jun 2015 15:07:42 GMT

<html><head><title>Apache Tomcat/7.0.56 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 403 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>Access to the specified resource has been forbidden.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.56</h3></body></html>

我已经验证myuser是具有发布功能的有效Artifactory用户(尤其是对于libs-release-local)并且密码是正确的。我知道有一个Artifactory-Gradle插件,但由于这个问题范围之外的原因,我对它不感兴趣;我希望使用curl来实现这一点。

1 个答案:

答案 0 :(得分:2)

您获得的403响应由Tomcat而不是Artifactory返回。 您可以通过查看Apache-Coyote/1.1而不是Artifactory/3.8.0的服务器标头值以及响应上下文类型为text/html而不是application/json来确定这一点(Artifactory使用JSON for REST API错误消息) 这通常表示您使用的是错误的URL,可能缺少神器Webapp上下文。例如,部署到

http://localhost:8081/libs-release-local

而不是

http://localhost:8081/artifactory/libs-release-local

如果问题与Artifactory用户权限有关,则应该收到类似于

的错误消息
{
  "errors" : [ {
    "status" : 403,
    "message" : "User myuser is not permitted to deploy 'com/me/myapp/myapp/0.1.20/myapp-0.1.20.jar' into 'libs-release-local:com/me/myapp/myapp/0.1.20/myapp-0.1.20.jar'."
  } ]
}