Artifactory


Intro

My notes on jFrog's artifact manager.



Tips and Tidbits


  • Artifactory's NuGet package ID search box is case sensitive!  Searching for "jquery" will not find the package "jQuery".  Argh!




CLI Interface

Artifactory has a CLI interface.



CLI Configuration

The CLI's configuration is saved to ~/.jfrog/jfrog-cli.conf  


One of the first things you should do is save the API key to your Artifactory instance.  Get your API key by following these steps.


Config API Key
jfrog rt config Trial --url https://rogercruz.jfrog.io/rogercruz --apikey=<api key>

Note that for the trial URL, you should not include the webapp part of the URL.


To make sure it all works, try the ping command.

Ping Artifactory
jfrog rt ping
OK


Use the show command to view the configuration

Show Configuration
jfrog rt config show
Server ID: Trial
Url: https://rogercruz.jfrog.io/rogercruz/
API key: <key>
Default:  true



REST API


Get NuGet Package


  • HTTP GET to https://<instance>/api/nuget/<nuget repo name>/FindPackagesById()?id='<package name>'



Build Integration

Artifacts from a build job and its dependencies can be captured by Artifactory so you can provide a BOM of what went into a build.  The called this the Build Info JSON file and it is stored in the artifactory-build-info repo.

Start by reading here: https://www.jfrog.com/confluence/display/RTF/Build+Integration


Generic build integration provides Build Info support for the following runner types: (source: JFrog)

  • Command Line
  • FxCop
  • MSBuild
  • Rake
  • Powershell
  • XCode Project
  • NuGet Publish
  • NAnt
  • Visual Studio (sln)
  • Visual Studio 2003
  • SBT, Scala build tool


JFrog provides a CLI for build integration that makes it easier to capture build dependencies.  By adding --build-name and --build-number to certain commands, the CLI collects and records the build info locally. This information can then be uploaded to Artifactory to the artifactory-build-info repo.



Collecting NuGet Build Information

The CLI provides a nuget command to invoke your NuGet client while at the same time it tracks the NuGet packages downloaded.  As of 6/2019, it only supports a "restore" of a project's NuGet dependencies and an upload.  I didn't see a command to do a nuget install, which could be useful if your scripts install packages that way.


To use, first make sure that your NuGet client is in your PATH.


Example of nuget restore:

.\jfrog rt nuget --solution-root C:\users\Roger\source\repos\LearningWCF\TravelAgencyInitialService\ restore nuget-local

[Info] Running nuget...
MSBuild auto-detection: using msbuild version '15.8.169.51996' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\bin'.
Nothing to do. None of the projects in this solution specify any packages for NuGet to restore.


My attempts to get the NuGet dependency for a project whose NuGet usage is defined in a packages.config file in the directory specified by the argument -PackagesDirectory

jfrog rt nuget restore nuget.local --nuget-args  "-PackagesDirectory . -Source nuget.org" --build-name=rogers-build --build-number=3


I then uploaded the build job.

jfrog rt bp rogers-build 3


But the JSON uploaded to the artifactory-build-info doesn't show any dependencies.



I then found out where the CLI keeps the temporary build info to see any files showed a list of NuGet dependencies and I didn't find any.  JFrog keeps its files in %temp%\jfrog\builds



To add dependencies to the build info use this:

jfrog rt bad rogers-build 4 .\jQuery.1.4.2\jQuery.1.4.2.nupkg


To request that a specific build be scanned by XRay use this command (you need to set a watch on the build name first)

jfrog rt build-scan rogers-build 4
[Error] Xray does not have any Watches monitoring this build, or the Watches monitoring this build do not have a CI Integration action defined.




Enabling CLI Debugging


You can enable more verbose output from the CLI

 $ENV:JFROG_CLI_LOG_LEVEL="DEBUG"




Repo Types


Artifactory supports the following types of repos (as of 6/2019).



The artifactory-build-info repository is automatically created and used by default to store build information. It cannot be removed.



Documentation




Other Interesting Stuff