JFrog CLI can help in setting up automation for managing your Artifactory repositories. You can create, update and delete local, remote and virtual Artifactory repositories.
Here's what you need to do:
1. Install JFrog CLI
Install JFrog CLI from https://jfrog.com/getcli/
2. Configure your JFrog instance
Configure the connection details of your JFrog instance by running the following command:
jfrog c add my-instance
3. Create a repository template
Run the following command:
jfrog rt rpt repo-conf-template.yml
This command will create a template file named repo-conf-template.yml in the current directory, with your repository configuration.
This is an interactive command, which prompts you with a series of questions. You have the option of using variables as values for the questions. For example, when prompted to provide the Repository Key, you can provide ${my-repo-key} as the value. This allows replacing the variable my-repo-key with any repository key value, when the template is used. This way, you can use the exact same configuration, to create a new repository, and only set a new repository key every time.
4. Creating, updating or deleting a repository
Now that you have the template ready, you can use it to create and update repositories as part of your automation scripts. Let's say that you'd like to create a repository using the repo-conf-template.yml template you created, which includes the ${my-repo-key} variable for the repository key. You should then use the jfrog rt rc command as follows.
jfrog rt rc repo-conf-template.yml --vars "my-repo-key=my-actual-repo-name"
Note that you can set values for multiple variables, by using the following format for --vars using the following format:
--vars "key1=value1;key2=value2;..."
You can use the similarly the jfrog rt ru to update a repository using a template.
To delete this repository, run the jfrog rt rdel as follows.
jfrog rt rdel my-actual-repo-name
Read more about managing repositories with JFrog CLI here