I am new to Artifactory, and I wonder how to upload a directory structure containing many different binaries -- keeping the structure intact -- to an artifactory?

  • 2
    Archives like zip and tar are made exactly for this, a single artifact with multiple files within, with their rights and mode. – Tensibai Jul 26 '18 at 5:37
  • yes, we can use zip or tar for upload, can you please help me if we can get the same structure in the artifactory after the upload (something like unzipping the uploaded zip or tar) – user_9090 Jul 26 '18 at 9:58
  • Well, yes, that's what they are for, tar was primarily a backup system (tar means tape archive), so it will unpack the same structure as was packed. – Tensibai Jul 26 '18 at 11:44
  • yes, but if we want it to extract on the Artifactory only, can this be possible? – user_9090 Jul 26 '18 at 11:49
  • 2
    No, multiples files are not an artifact by definition, if all files are independent, then they are multiple artifacts by themselves – Tensibai Jul 26 '18 at 11:55

This can be done through the Jrog CLI. The CLI has a recursive option that looks like it will do what you hope.

jfrog rt upload --recursive artifactory-mirror/* artifact-repo/dir-struct/

The CLI also has some performance improvements for uploads that doing it through curl or a browser don't seem to get. Also, scriptable!

To include full directory structure you will want to use the flag --flat=false

jfrog rt upload --flat=false --recursive artifactory-mirror/* artifact-repo
  • Can we execute the JFrog CLI command on jenkins? – user_9090 Jul 27 '18 at 6:53
  • @Gaurav Definitely, there are command-line flags for the API key and server URLs. We'll be doing it before too long. – sysadmin1138 Jul 27 '18 at 13:23
  • "flat:false" should be "flat=false". – Étienne Dec 10 '20 at 15:18
  • wildcard asterisk * should either be omitted, or else the string placed in "quotes". – Sam Mar 30 at 18:42

Since the original question is also tagged with Nexus this is how to do bulk upload with Nexus 3:

find <directory name>/ \! -type d -print0 | xargs -P10 -0 -I@ curl -v --user <user>:<password> --upload-file ./@ http://localhost:8081/repository/<repository name>/@

Adding on @sysadmin1138's answer, to push the content of a folder to another folder while keeping the directory structure starting from the source folder, you can use:

(cd source-folder && jfrog rt upload --detailed-summary --flat=false --recursive ./ artifact-repo/target-folder/

The --detailed-summary will tell you the details of all the files uploaded.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.