Occasionally, teams working on different projects may need to copy or move artifacts from one project to another. This can be achieved using the Copy Item and the Move Item REST API calls. As of the time of writing this article, copying or moving content between projects is not available via the UI. Copying/moving content via the UI is possible for repositories within the same project.
If a user wishes to copy content from a local repository in project1 to a local repository in project2, the user has to have write permissions to the target repository in project2. To overwrite the existing content, the user will also need to have “Delete” permissions for the target repository. More information on repository permissions can be found here.
In the example below, we move the content of the proj2-repo-local repository to the proj1-repo-local repository:
$ curl -XPOST -u username:password "https://ART_HOST/artifactory/api/move/proj2-repo-local?to=proj1-repo-local" { "messages" : [ { "level" : "INFO", "message" : "moving proj2-repo-local: to proj1-repo-local: completed successfully, 1 artifacts and 1 folders were moved" } ] }
In the following example, we copy the contents of the proj2-repo-local test folder to the proj-repo-local test1 folder:
$ curl -XPOST -u username:password "https://ART_HOST/artifactory/api/copy/proj2-repo-local/test?to=proj1-repo-local/test1" { "messages" : [ { "level" : "INFO", "message" : "copying proj2-repo-local:test to proj1-repo-local:test1 completed successfully, 1 artifacts and 1 folders were copied" } ] }
To test the copy/move command using dry run, we can use the dry=1 flag in the command. For example:
api/copy/proj2-example-repo-local/test?to=proj-example-repo-local/test1&dry=1"