简体   繁体   中英

What is the idiomatic way of copying Artifactory files?

I have an Artifactory repository with this folder structure:

 root
└──  foo
    └──  file.txt

I would like to copy file.txt into a folder called "bar" and rename it:

 root
└──  foo
    └──  file.txt
└──  bar
    └──  new_file.txt

I expected this JFrog CLI command to accomplish this:

> jf rt copy root/foo/file.txt root/bar/new_file.txt

But instead, it results in this folder structure:

 root
└──  foo
    └──  file.txt
└──  bar/foo
    └──  new_file.txt

This seems counterintuitive to me, and at the very least is totally different than how the usual file-system commands function.

I've been able to work around this with the following commands, making use of JFrog placeholders:

> jf rt copy "root/foo/(file.txt)" "root/bar/{1}" # First copy the file to the new folder
> jf rt move "root/(bar)/file.txt" "root/{1}/new_file.txt" # Then rename it

But there must be a better way, right?

I should also mention that this appears to be an issue with all Artifactory clients (the REST API, etc.). I'm using the JFrog CLI in this example for ease of reproduction.

'flat' option will do the job

--flat  
[Default: false]

If true, artifacts are copied to the exact target path specified and their hierarchy in the source path is ignored.

If false, artifacts are copied to the target path while maintaining their source path hierarchy.

command to run in your case:

jf rt copy root/foo/file.txt root/bar/new_file.txt --flat=true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM