1

I have a (Gradle-built) project that produces a JAR at <projectRoot>/build/libs/myapp-<version>.jar. I am now trying to write a curl command that publishes that JAR to Artifactory like so:

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"

When I run this in the console I get:

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>

I have verified that myuser is a valid Artifactory user with publish capabilities (especially for libs-release-local) and that the password is correct. I am aware that there is an Artifactory-Gradle plugin, but for reasons outside the scope of this question I am not interested in it; I want to get this working using curl.

smeeb
  • 27,777
  • 57
  • 250
  • 447
  • 1
    are you able to deploy this file from the UI using the same user? What time of permissions does the user have for the libs-release-local repository? – Dror Bereznitsky Jun 02 '15 at 08:33
  • Thanks @drorb (+1) - yes `myuser` can deploy the same artifact via the UI and has write/publish permissions for `libs-release-local`. – smeeb Jun 02 '15 at 09:47
  • 1
    are you overriding an existing artifact? in this case you will also need DELETE permissions. In addition what do you see in the Artifactory access log? – Dror Bereznitsky Jun 02 '15 at 09:49
  • Thanks @drorb (+1 again) - yes the user has DELETE permission on the repo. Per the access log, where can I find that? Is it viewable through the UI or is it a file on the Artifactory server (if so, what's the name + path to the file)? Thanks again! – smeeb Jun 02 '15 at 14:12
  • Logs can be found in ARTIFACTORY_HOME/logs or from the UI in Admin > Advanced > System Logs – Dror Bereznitsky Jun 02 '15 at 15:14
  • I remember Gradle do have maven deploy plugin. Just wonder why you are not using that and craft it yourself... – Adrian Shum Jun 03 '15 at 08:33

1 Answers1

3

The 403 response you are getting is returned by Tomcat and not Artifactory. You can determine this by looking at the Server header value which is Apache-Coyote/1.1 instead of Artifactory/3.8.0 and by the fact that the reponse context type is text/html rather than application/json (Artifactory uses JSON for REST API error message).
This usually indicates that you are using a wrong URL, probably missing the artifactory webapp context. For example, deploying to

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

instead of

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

In the case the issue was related to Artifactory user permission, you should have a got an error message similar to

{
  "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'."
  } ]
}
Dror Bereznitsky
  • 20,048
  • 3
  • 48
  • 57
  • 1
    You nailed it! In my case I was not using curl but the `jfrog` CLI tool. I was incorrectly passing the target path as `/myapp.zip` instead of `artifactory//myapp.zip` One thing that I noticed is that `/artifactory//myapp.zip` also seemed to work. – donhector May 03 '18 at 21:55