How to create and update repositories with JFrog CLI? [Video]

How to create and update repositories with JFrog CLI? [Video]

AuthorFullName__c
Or Naishtat
articleNumber
000004961
ft:sourceType
Salesforce
FirstPublishedDate
2020-12-23T12:41:58Z
lastModifiedDate
2024-03-10T07:47:16Z
VersionNumber
8

In this video we will learn how to create and update repositories with JFrog CLI.



 

Hi, my name is Or from JFrog support, and in this short video, I will show you how to create and update repositories using in JFrog CLI. Please note, I will purposely make a mistake doing this video so we can learn how to fix it. So Let's start with, jfrog rt, for artifactory, and what we want to do is to create a template. The template will hold the configurations of the repository that we want to create or update. So repo-template and we will give it a name, local repository. So here we can choose if this template will be for creation or update, we will choose create, and here we will need to choose a name for the repository. We will call it local repository, and a repository class. It can be local, remote and virtual.

We will choose local and here we can choose the type of the package. We will go for generic and configuration key, and here you have all the options that can be applied to our local repository, include patterns, notes, description, x-ray Index, just all the options that you can add to your repository. You can see them in the UI When you edit the repository.

At the moment, we don't need any configurations. Let's do the same and create the remote repository. So, jfrog rt repo-template remote repository. So the template type, again, will be create. We will call it remote repository, and now we will choose remote. Let's give it a URL and generic as well. We can add more configurations to the repository like username, password. As you can see, the options are different between the local repository and the remote repository. So now that we have the templates, we want to apply them to Artifactory. To do that we will use, jfrog rt repo-create, and the name of the template that we want to apply. In our case, we had the local repository and let's do the same for the remote repository. If we go to Artifactory now, you can see that my artifactory instance has no repositories. After I refresh, I have the local repository and the remote repository.

Now that we have a local repository and a remote repository, I want to create a virtual repository that will hold proof of them. So we will do the same. jfrog rt repo-template virtual-repository. Create, virtual repository, and generic. So in the virtual repository, we can choose which repositories will be included. As you can see returning the output, "The value needs to be comma separated list." Please pay attention. It's only a comma separation and not comma-space. So the first will be our local repository and the second the remote. We don't need anymore. Great, so let's do the same. As you can see, we have a mistake here. The errors with the CLI are very clear. The message is, "Repository remote-repo does not exist." That's true because that's not the name that we gave the repository. We called it remote-repository and not remote-repo. So how can we fix this?

Essentially, what template is, is adjacent file that is uploaded to Artifactory. So, if I look in my directory I can see the virtual-repository template. Let's go in and edit it. In here you can see remote-repo. This is our mistake. So if we make a little mistake, we don't need to go and make the whole process again. We can go into the template file itself and fix it. Let's save, and again, jfrog rt repo-create virtual-repository. Voila, it works.

If we go to Artifactory, you can see we have a virtual-repository and it holds the local-repository and the remote-repository. So now that we have a remote-repository and the local-repository on the one virtual-repository, we see that we have a new-remote-repository here. To edit to the virtual repository, we don't need to delete or create the virtual repository again. We can use the update template to update the virtual-repository with the new-remote-repository. We will use the same command, jfrog rt repo-template, and we'll call it, updater. Template type, for now will be update and the repository key, which will be the virtual-repository that we want to update. The class will be virtual and the package type was generic. And now we will choose repositories and we will give it the repositories that are already in it. In addition to the new one. Now I want to note something, the update will override the older configurations of the repository. Meaning if we only put new-remote-repository, then only the new-remote-repository will be under the virtual-repository.

This is why we write all of them. And we need no more configurations, and now we can use the update command, jfrog rt repo-update, and updater template. So now we can see the three repositories are under the virtual-repository. So that was my video on creating and updating repositories with JFrog CLI. Thank you for watching and I hope you enjoyed. Please feel free to leave a feedback and comments in the comment section below.