Is there any way to create empty folder in Artifactory repo

696 views Asked by At

I wanted to create empty folder in artifactory repo. I created an empty folder with desired name in local file system and given that path to jf rt u command.

jf rt u <path/to/empty/folder> <destination/to/artifactory> 

But it didn't work. Is there any other way to create empty folders in artifactory repo.

Thanks in advance ...!!

2

There are 2 answers

4
Radhika Bhoyar On BEST ANSWER

Yes, Artifactory doesn't natively support creating empty folders directly.

One workaround is to create an empty file within the folder and then upload it. You could use a command like touch or similar to create an empty file within the folder and then upload that to Artifactory.

Here's a step-by-step process in doing so:

  1. Create an Empty File:

On your local system, navigate to the desired folder and create an empty file using the command line. For example:

touch emptyfile.txt

This command creates an empty file named emptyfile.txt.

  1. Upload the Empty File to Artifactory:

Use the jf rt u command to upload the empty file to Artifactory. Modify the command according to your specific paths:

jf rt u /path/to/emptyfile.txt <destination in Artifactory>

Replace /path/to/emptyfile.txt with the actual path to your empty file and with the path where you want to upload the empty file.

  1. Result:

Once the empty file is uploaded to Artifactory, it will appear as a file. However, since it's an empty file, it effectively creates the appearance of an empty folder within Artifactory.

This method essentially tricks Artifactory into displaying an empty folder by uploading an empty file within it.

2
Tom.A On

Alternative way to using JFrog CLI is to create a folder using the Artifactory REST API, you should indicate your intention by adding a forward slash at the end of the folder name in the API endpoint. This helps Artifactory understand that you want to create a folder rather than a file.

Example:

curl -u<username>:<password> -XPUT "http://my.jfrog.artifactory:8081/artifactory/generic-local/a/"

This will upload a directory called 'a' under an existing repository generic-local of type 'Generic'

Note: The generic-local should exist prior to adding the sub folder.