How to collect and publish build-info using JFrog CLI? [Video]

How to collect and publish build-info using JFrog CLI? [Video]

AuthorFullName__c
Patrick Russell
articleNumber
000004982
FirstPublishedDate
2021-01-21T11:51:53Z
lastModifiedDate
2025-06-11



 

Hello everyone and welcome to another video. I'm Patrick with JFrog support and today I'd like to go over how to get started with the JFrog CLI. In today's video we'll be covering the following topics: First, we'll discuss what the JFrog CLI is, then we'll talk about how to install it and configure it, then we'll move on to some basic upload and download commands, and finally we'll cover the JFrog CLI's build integrations.

First, what is the CLI? The JFrog CLI is a command line interface designed to work with JFrog's products. It supports all of the JFrog REST API endpoints, and it makes complex API operations much, much easier. It is also very automation-friendly. By the way, it's used in our build plugins, meaning that some of you are already using the JFrog CLI without realizing it.

To install the JFrog CLI, go to jfrog.com/getCLI. You can then choose from a variety of installation methods. When you've selected one you prefer, go ahead and copy-paste the command into your terminal. Then it's a matter of configuring the JFrog CLI. The command to use is jf config add. The JFrog CLI will present you with a form that you can then fill out to connect to Artifactory. First, you'll need to choose a unique name for the configuration, then supply the JFrog URL. Notice that there should not be a /artifactory in the URL prompt, that gets added in for you. Finally, you need to choose an authentication method such as a username, password, or an identity token. By the way, you can skip the config form by supplying these arguments as command line flags.

I already have the JFrog CLI installed, so let's configure it. You can type in jf config add. Let's enter a unique identifier, remember to make it something easy to type. For the URL, let's go ahead and put in localhost port 8082. As discussed earlier, the context such as /artifactory is added in for you. Finally, we need to authenticate. I'm going to be using the username and password, but you can also use an access token, a web login, or the mutual TLS option. And that's it, we're ready to go! To confirm things are looking good, you can type in jf config show and this will print the configurations. If you need to edit a configuration, you can type in jf config edit and then the name of the config you wish to edit. Finally, if you need to remove the configuration, you can type in jf config rm and then the name of the configuration.

Next, let's talk about how to upload and download via the JFrog CLI. To download files, you use the command jf rt dl. You then need to supply the name of the file up in Artifactory that you wish to download. Finally, if you want, you can supply a specific path on the local file system to save the file to. For example, you can download this JAR file from the libs-release folder into your rd directory by following this syntax. The same sort of syntax in reverse is used to upload files. This time, run jf rt u for upload, and then select a file on the local file system. You then supply the name of a repository and the destination folder path.

Let's start by downloading a file. In my Java directory, I need to download and install a Maven Java file. If I head over to my Artifactory, you can see that under my Maven remote I have com jfrog and then this example dependency tree JAR. I'm going to go ahead and grab the repository path line and paste that into the command. This command will request the JAR file from the Artifactory remote repository cache. I have successfully downloaded the file. It has saved it to the com jfrog maven dep tree folder within my directory. If you wish to upload a file to Artifactory, you do things in the opposite form.

This is my local file system and I am specifying the dep tree JAR file I just downloaded. Let's upload it to libs-release-local. Over in my libs-release-local, you can see the file.

Let's head back to the presentation. Finally, the JFrog CLI is able to track uploads and downloads in order to create build information that is then published to Artifactory. For example, you can use the same upload and download commands with these extra tags. By supplying a name and number, the JFrog CLI will record in the temp directory of your computer an incomplete build-info.json file. Once you have completed your build, you can then publish it to create a build in Artifactory's build integration system. This also works with package managers. The JFrog CLI supports many different package managers by hooking into the command line interface of that manager. For example, you can use the jf npm install command along with the build name and build number flags to track the dependencies NPM installs in your project. After you are done publishing the NPM binary files, you can then publish the Artifactory build info object by running jf rt bp. It is also easy to get a scan report from JFrog X-ray by calling jf rt build scan, supplying the name and number here allows Artifactory to request a scan from JFrog X-ray.

Back in my Java project, let's do the same operations but this time simulate a build. I am going to rerun the download command and now I'm going to add on at the end build-name mvn example and a build number of 1. Success! Let's rerun the upload command. Also a success! Let's run jf rt build publish mvn example 1.

I have downloaded one file as a dependency and uploaded one file as my published artifact. Let me also demonstrate an NPM build. Up in my directory, I have an NPM folder and an example project. First, we need to run jf npm c. This is short for npm config. First, we need to say that we want to resolve dependencies from Artifactory. We will then be specifying the server ID and the repository to use. We also need to tell the CLI that we want to deploy artifacts to Artifactory. It has the same questions. We're ready to go! Let's try jf npm install and build name and build number. The JFrog CLI will now hook into the NPM client and tell it to resolve dependencies from Artifactory. It will then track them in the build info file. We have done an NPM install successfully. Now we will do jf npm publish. Success! We're almost done. We also need to publish the build information. The JFrog CLI makes it easy to track any existing package manager build.

That's basically it! If you have any questions, feel free to ask by leaving a comment below or you can reach out to us by email over in the JFrog Help Center. Thank you for watching, have a good day.