Use the Knife Command Line

JFrog Artifactory Documentation

Products
JFrog Artifactory
Content Type
User Guide

Chef repositories must be prefixed with api/chef in the path

When accessing a Chef supermarket through Artifactory, the repository URL must be prefixed with api/chef in the path. This applies to all Knife commands.

For example, if you are using Artifactory standalone or as a local service, you would access your Chef supermarket using the following URL:

https://localhost:8081/artifactory/api/chef/<repository key>

Or, if you are using Artifactory Cloud, the URL would be:

https://<server name>.jfrog.io/artifactory/api/chef/<repository key>

The Knife command line is installed automatically as part of Chef Workstation.

Once you have created your Chef supermarket, you can select it in the Tree Browser and click Set Me Up to get code snippets you can use to change your Chef supermarket URL, and deploy and resolve packages using the knife command line tool.

Set the default Chef supermarket with a URL pointing to a Chef supermarket in Artifactory by editing your ~/.chef/knife.rb configuration file (the example below uses a repository with the key chef-virtual ). You authenticate the request using your username and password or with your Artifactory API key :

Setting the default Chef supermarket for Knife with credentials

In order to configure your Knife client to work with Artifactory, you need to edit its knife.rb file (which can usually be found under <user-home-dir>/.chef/) and add a reference to your Artifactory Chef repository as a "supermarket_site". For example:

knife[:supermarket_site] = 'https://company.jfrog.io/artifactory/api/chef/chef-local'

To support authentication, which may be required by Artifactory, you need to install the knife-art plugin.

config.rb file location

The config.rb file, which replaces the knife.rb file, doesn't exist by default. It can be created with the knife configure command. For more information, including possible file locations, see knife documentation. The location of this file can be overidden with the --config parameter when running a knife command.

If there is no config.rb file, knife looks for a knife.rb file as a fallback.