When using the RubyGems command line to access a repository through Artifactory, the repository URL must be prefixed with |
All RubyGems commands, including gem source
and gem push
,
must prepend the repository path with api/gems
.
For example, if you are using Artifactory standalone or as a local service, you would access your RubyGems repositories using the following URL:
http://localhost:8081/artifactory/api/gems/<repository key>
Or, if you are using Artifactory Cloud, the URL would be:
https://<server name>.jfrog.io/artifactory/api/gems/<repository key>
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 Administration module, under Repositories | Repositories | Local, click New Local Repository and set Gems 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.
When using the RubyGems command line to access a repository through Artifactory, the repository URL must be prepended with |
gem source -a http://localhost:8081/artifactory/api/gems/my-gems-local/ |
Upon creation of a Local RubyGems repository, Artifactory populates it with the following set of files that are required for indexing the repository:
rubygems-update-*.gem
(created under the gems
folder of the repository)quick/Marshal.*
latest_specs.*.gz
prerelease_specs.*.gz
specs.*.gz
The local RubyGems repository is displayed in the Application module | Artifactory | Artifacts.
First, setup the appropriate credentials for the gem tool: either include the API key in the ~/.gem/credentials
file or issue this command:
curl http://localhost:8081/artifactory/api/gems/<repository key>/api/v1/api_key.yaml -u admin:password > ~/.gem/credentials |
You may need to change the permissions of the credentials file to 600 ( |
The credentials file is located under You also need to set the API key encoding to be "ASCII". For example: curl |
You can modify the credentials file manually and add different API keys. You can later use |
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:
export RUBYGEMS_HOST=http://localhost:8081/artifactory/api/gems/<repository key> |
To get this value, select your repository in the Application module | Artifactory | Artifacts | Gems-local 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 Also, make sure you are familiar with your global When a local repository is first created, it is populated with |
When deploying Gems to your repositories, you need to place them in a gems folder for Artifactory to include them in its indexing calculations. |
A remote RubyGems repository serves as a caching proxy for a repository managed at a remote URL such as .
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:
Add this URL by modifying your ~/.gemrc
file or using the gem source
command as follows:
When using the RubyGems command line to access a repository through Artifactory, the repository URL must be prefixed with |
gem source -a http://localhost:8081/artifactory/api/gems/rubygems/ |
You can remove previous source entries by modifying your |
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:
|
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.
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!)
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 API Gem commands are supported:
Gem command | Curl syntax example | Remarks |
---|---|---|
Info | curl http://localhost:8081/artifactory/api/gems/<repository key>/api/v1/gems/my_gem.(json|xml|yaml) | Optionally indicate JSON / XML / YAML (default: JSON) |
Search | curl http://localhost:8081/artifactory/api/gems/<repository key>/api/v1/search.(json|xml|yaml)?query=[query] | Will search for gems with name containing query |
Dependencies | curl http://localhost:8081/artifactory/api/gems/<repository key>/api/v1/dependencies?gems=[gem1,...] | Use a csv of gem names for the value of gems |
Yank |
| Deletes the specific gem file from the repository |
Indexing is done automatically by Artifactory in the background, however if you still need to recreate or update the spec index files, the following REST API commands are also available:
REST command | Curl syntax example | Remarks |
---|---|---|
ReIndex | curl -X POST http://localhost:8081/artifactory/api/gems/<repository key>/reindex | Re-creates all spec index files. |
Update index | curl -X POST http://localhost:8081/artifactory/api/gems/<repository key>/updateIndex | Updates all spec index files if needed. |
If you select a RubyGems artifact in the Tree Browser you can select the RubyGems tab to view detailed information on the selected artifact.
The Bundler Compact Index feature allows you to retrieve the latest RubyGems version compatible with your installed Ruby version in the project applies to local, remote, and virtual repositories.
To apply this feature, set the artifactory.gems.compact.index.enabled=true
value in the artifactory.system.properties
file.
<iframe width="560" height="315" src="https://www.youtube.com/embed/4wuYHBpnnp8" frameborder="0" allowfullscreen></iframe> |