Introduction
In JFrog Artifactory, properties are metadata attributes that can be assigned to stored artifacts, folders, or repositories. These properties significantly improve the management, searchability, and retrieval of these entities, providing meaningful context and information.
In this Knowledge Base article, we will explore how to set properties at the folder level using the user interface (UI), REST API, and JFrog CLI.
Setting properties using UI
To set properties at the folder level using the UI, follow these simple steps:
- Navigate to the desired folder within your repository in the Tree view.
- Add the properties as needed.
For visual clarity, see the example screenshot below, where we have added a property with the Key as “UI-property” and the Value as 1.0.
Additionally, if you want the property to be applied recursively to all subfolders and artifacts within this folder, simply select the Recursive checkbox. This will ensure that the property takes effect throughout the entire hierarchy.
Setting properties using REST API
When using the REST API to set properties at the folder level, it's important to note that properties are set recursively by default. If you'd like to apply the property non-recursively, you must specify recursive=0 in your command.
Here’s the command you would need to execute:
curl -u<username>:'password' -XPUT "https://<JPD_URL>/artifactory/api/storage/property-testing-local/folder1/folder2?properties=restapi=12345&recursive=0"
After running this command, you should see the updated properties reflected in the UI as shown in the screenshot below.
Setting properties using JFROG CLI
Before using JFrog CLI to set properties, ensure that the CLI is properly configured with your Artifactory instance. Once configured, you can utilize the set-props command to apply properties at the folder level.
Here's a sample command to set properties:
jf rt set-props "property-testing-local/folder1/folder2" "cli=123" --include-dirs=true --recursive=false
Upon successful execution of this command, the property will be added to the specified folder, which can be verified through the UI as illustrated in the screenshot below.
Conclusion
You have now successfully added properties to a folder using the UI, REST API, and JFrog CLI. For further reading and to deepen your understanding, please refer to the following resources:
- Item Properties APIs
- Add and Delete Properties via UI
- JFROG CLI Documentation