0

I've been researching for some time and am having trouble translating what I've found into what I can use. I'm trying to send ant artifacts to Artifactory from Jenkins--I'm trying to do this with a shell script. I know you can POST with curl, I'm essentially trying to turn the following into a POST:

PUT /libs-release-local/my/jar/1.0/jar-1.0.jar
{
"uri": "http://localhost:8080/artifactory/libs-release-local/my/jar/1.0/jar-1.0.jar",
"downloadUri": "http://localhost:8080/artifactory/libs-release-local/my/jar/1.0/jar-1.0.jar",
"repo": "libs-release-local",
"path": "/my/jar/1.0/jar-1.0.jar",
"created": ISO8601 (yyyy-MM-dd'T'HH:mm:ss.SSSZ),
"createdBy": "userY",
"size": "1024", //bytes
"mimeType": "application/java-archive",
"checksums":
{
        "md5" : string,
        "sha1" : string
    },
"originalChecksums":{
        "md5" : string,
        "sha1" : string
    }
}

I've found https://superuser.com/questions/149329/what-is-the-curl-command-line-syntax-to-do-a-post-request & http://curl.haxx.se/docs/httpscripting.html#POST

Would it be a sequence of curls? like

curl --upload-fil "/libs-release-local/my/jar/1.0/jjar-1.0.jar"
Curl -X POST --URI "http://localhost:8080/artifactory/libs-release-local/my/jar/1.0/jar-1.0.jar"

etc..?

curl -X POST

Community
  • 1
  • 1
  • 1
    Glancing at [the API docs](http://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API#ArtifactoryRESTAPI-DeployArtifact) (whence your example seems to have come) it looks like it expects a PUT. Why are you trying to do a POST instead? – Jordan Running Aug 22 '14 at 20:25
  • possible duplicate of [How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?](http://stackoverflow.com/questions/7172784/how-to-post-json-data-with-curl-from-terminal-commandline-to-test-spring-rest) – Jordan Running Aug 22 '14 at 20:27
  • I do need to use a PUT, I'm not sure why I typed POST. Thank you! –  Aug 28 '14 at 21:40

1 Answers1

3
  1. You don't need 2 curl requests, only one.
  2. You need to issue a PUT request, not POST.

curl -u user:password --upload-file myjar.jar "http://localhost:8080/artifactory/libs-release-local/my/jar/1.0/jar-1.0.jar"

JBaruch
  • 22,610
  • 5
  • 62
  • 90