If you are using Artifactory version 3.4.1 and below, you need to define the following System Property and restart Artifactory:

In Artifactory version 3.4.2, an enhancement has been implemented to overcome this issue and from this version on, no action is required.

Local Repositories

Local RubyGems repositories are physical, locally-managed repositories into which you can deploy and manage your in-house Gems.

To create a local RubyGems repository, in the Admin module, under Repositories | Local, click "New"and set RubyGems to be the Package Type.

You can set up a local RubyGems repository as follows:

You need to add the repository source URL by modifying your ~/.gemrc file or using the gem source command as displayed below. You can extract the source URL by selecting the repository in the Tree Browser and clicking Set Me Up.

Notice that there are two sources. First, the remote proxy, then the local one. This will effectively allow you to retrieve Gems from both of them in the specified order.

All RubyGems repositories must be prefixed with api/gems in the path

When using the RubyGems command line to access a repository through Artifactory, the repository URL must be prepended with api/gems in the path.

Usage

First, setup the appropriate credentials for the gem tool: either include the API key in the ~/.gem/credentials file or issue this command:

Setting Up Credentials

Running on Linux

You may need to change the permissions of the credentials file to 600 (chmod 600)

You can modify the credentials file manually and add different API keys. You can later use gem push -k key to choose the relevant API key.

In order to push gems to the local repository, you can set the global variable $RUBYGEMS_HOST to point to the local repository as follows:

Setting RUBYGEMS_HOST

To get this value, select your repository in the Tree Browser and click Set Me Up.

Alternatively you could use the gem push command with --host, and optionally, --key to specify the relevant API key.

Make sure you are familiar with your effective sources and their order as specified in the ~/.gemrc file.

Also, make sure you are familiar with your global $RUBYGEMS_HOST variable before you issue a gem push command or use the push --host option.

When a local repository is first created, it is populated with rubygems-update-*.gemby default. In order to disable this behavior, you must change the System Properties to include: artifactory.gems.gemsAfterRepoInitHack=false

Remote Repositories

A remote RubyGems repository serves as a caching proxy for a repository managed at a remote URL such as
http://rubygems.org.

Once requested, artifacts (Gems) are cached on demand. They can then be removed, but you cannot manually deploy anything into a remote repository.

To create a remote RubyGems repository, execute the following steps:

in the Admin module, under Repositories | Remote, click "New"and set RubyGems to be the Package Type.

Set the Repository Key, and specify the URL to the remote repository. The example below references
rubygems.org.

Usage

In order to allow the integration with the gem command line tool, you must add the relevant source URL to your RubyGems configuration.

In the Tree Browser, select your newly created repository and click Set Me Up.

Copy the source URL from the RubyGems Sources section.

Add this URL by modifying your ~/.gemrc file or using the gem source command as follows:

All RubyGems repositories must be prefixed with api/gems in the path

When using the RubyGems command line to access a repository through Artifactory, the repository URL must be prefixed with api/gems in the path.

Additional Gem Commands You Can Use

You can remove previous source entries by modifying your ~/.gemrc file manually or by running gem sources -r You can also run gem sources --list to know what your effective sources are and their order.

Overcoming Unauthorized Status Failures

Some gem/bundler commands may fail with an Unauthorized (401) status. In some cases these can be overcome by using one of the following options:

Enable the "Anonymous User" by checking Allow Anonymous Access in Security General Configuration as described in Managing Users.

Create a specialized Permission Target that allows anonymous access only to the remote repository.

Use a source URL with embedded credentials, such as: gem sources -a http://user:password@host/...

Virtual Repositories

A Virtual RubyGems repository (or "repository group") can aggregate multiple local and remote RubyGems repositories, seamlessly exposing them under a single URL.

The repository is virtual in that you can resolve and retrieve artifacts from it but you cannot deploy anything to it. For more information please refer to Virtual Repositories.

The procedure for setting up a virtual repository is very similar to setting up a local or remote repository, however as a last step, you need to select the repositories that will be included in the virtual repository you are creating.

Usage

Using a virtual RubyGems repository you can aggregate both your local and remote repositories.

You need to set the right repository source URL, in the same way as described in Usage for a local RubyGems repository, just with the appropriate repository key as follows:

source:http://localhost:8081/artifactory/api/gems/<repository key>/

target:http://localhost:8081/artifactory/api/gems/<repository key>(no slash at the end!)

Using the REST API

The REST API provides access to the Gems Add-on through the repository key using the following URL:

http://localhost:8081/artifactory/api/gems/<repository key>/

In addition to the basic binary repository operations, such as download, deploy, delete etc., the following
RubyGems.org API Gem commands are supported: