如何使用复杂的参数cURL PUT?

时间:2014-04-25 13:23:22

标签: rest curl artifactory http-put

注意:虽然这个问题涉及Artifactory API,但实际上更多的是编写半复杂的cURL命令。

说我在一个包含myapp-1.5.jar的目录中。我们还说我在http://artrepo01:8080/artifactory/libs-release-local有一个Artifactory仓库。

我想将JAR部署到:

libs-release-local/
    myorg/
        myapp/
            1.5/
                myapp-1.5.jar

根据Artifactory API docs(对于部署工件端点),正确的方法是通过HTTP PUT:

PUT /libs-release-local/my/jar/1.0/jar-1.0.jar
{
    "uri": "http://artrepo01:8080/artifactory/libs-release-local",
    "downloadUri": "http://artrepo01:8080/artifactory/libs-release-local",
    "repo": "libs-release-local",
    "path": "/myorg/myapp/1.5/myapp-1.5.jar",
    "createdBy": "artadmin",
    "mimeType": "application/java-archive",
}

问题:

  • 确切的cURL命令是什么才能正确地将JAR发送到此端点?
  • 当我尝试curl -X PUT http://artrepo01:8080/artifactory/libs-release-local/myorg/myapp/1.5/myapp.jar时(可能会或可能不正确,在哪种情况下不要担心上述问题),我从Artifactory收到错误,指出匿名用户对repo没有写入权限。我相信这是因为我的cURL命令没有指定createdBy用户(artadmin)。
  • 如何在PUT通话中指定artadmin用户的密码?

1 个答案:

答案 0 :(得分:1)

您的查询很好。只需使用-u标志添加用户名和密码:

curl -X PUT -u artadmin:password http://artrepo01:8080/artifactory/libs-release-local/myorg/myapp/1.5/myapp-1.5.jar