Configure Ruby and Bundler for Artifactory

Configure Ruby/Bundler for dependency resolution and publishing through Artifactory.

When to Use

Use jf ruby-config to save your Artifactory server and repository preferences for Ruby projects. After running it, complete the Bundler credential and source configuration steps described below — then bundle install will resolve gems from Artifactory.

Prerequisites

  • Ruby ≥ 3.0 and Bundler ≥ 2.3 must be installed.
  • Configure a server with jf c add (alias: jf config add).
  • Authentication to Artifactory is required.

Configuration: jf ruby-config

Generate Ruby/Bundler configuration for dependency resolution and publishing through Artifactory. Run this once per project before your first bundle install.

To configure Ruby/Bundler for Artifactory:

  1. From your project directory (or with --global), run jf ruby-config with resolve (and optionally deploy) server and repository flags (see Non-Interactive Configuration with Flags).
  2. Confirm .jfrog/projects/ruby.yaml (or the global path) was written (see How to Verify).

Synopsis

jf ruby-config [options]

Aliases: rubyc

Configuration Options

FlagDefaultDescription
--globalfalseSet to true for global configuration (all projects). Specific projects can override.
--repo-deploy(none)Optional. Repository for gem publishing.
--repo-resolve(none)Optional. Repository for gem resolution (bundle install).
--server-id-deploy(none)Optional. Artifactory server ID for deployment. Configure with jf c add.
--server-id-resolve(none)Optional. Artifactory server ID for resolution. Configure with jf c add.

Configuration Examples

View Help

jf ruby-config --help

Non-Interactive Configuration with Flags

jf ruby-config --server-id-resolve=<server-id> --repo-resolve=<repo-name>

Where:

  • <server-id>: The server ID configured using jf config add
  • <repo-name>: The name of the Ruby repository in Artifactory

For example:

jf ruby-config --server-id-resolve=my-server --repo-resolve=ruby-virtual

Global Configuration

jf ruby-config --global --server-id-resolve=<server-id> --repo-resolve=<repo-name>

What jf ruby-config Does

jf ruby-config saves your Artifactory server and repository preferences to a local config file:

  • Project-level (default): .jfrog/projects/ruby.yaml
  • Global (--global): ~/.jfrog/projects/ruby.yaml

It does not modify Bundler's native configuration. After running jf ruby-config, you must also configure Bundler to use Artifactory as a gem source or mirror — see After Configuration below.

👍

Shortcut

: In CI/CD, pass all flags non-interactively so the config step is fully automated and reproducible.

Configuration Notes

  • Config-only: There is no jf ruby command. After running jf ruby-config, complete the Bundler credential and source setup described in After Configuration.
  • Resolution and deployment: Use --repo-resolve for installing gems and --repo-deploy for publishing gems.
  • Run once per project: Re-run when changing repository assignments.

Expected Output

$ jf ruby-config --server-id-resolve=my-server --repo-resolve=ruby-virtual
[Info] ruby build config successfully created.

How to Verify

After running, confirm the config file was written:

cat .jfrog/projects/ruby.yaml

Expected content:

version: 1
type: ruby
resolver:
    repo: ruby-virtual
    serverId: my-server
📘

Note

: bundle config will not show any Artifactory-related settings at this point. The JFrog config file is separate from Bundler's native config. To make bundle install resolve from Artifactory, complete the steps in After Configuration.


After Configuration

jf ruby-config saves JFrog-side preferences but does not modify Bundler's native configuration. You must complete the following steps before bundle install will resolve from Artifactory.

To finish Bundler setup so gems resolve from Artifactory:

  1. Run jf ruby-config with your server and repository settings if you have not already:

    jf ruby-config --server-id-resolve=my-server --repo-resolve=ruby-virtual
  2. Configure Bundler credentials for your Artifactory host. Run once per machine (or inject via environment in CI):

    bundle config <artifactory-host> <username>:<access-token>

    For example:

    bundle config my-instance.jfrog.io my-user:AKCp...token...

    For CI/CD, use the environment variable form instead:

    export BUNDLE_MY__INSTANCE__JFROG__IO="my-user:AKCp...token..."

    Replace dots in the hostname with double underscores when forming the env var name (for example, my-instance.jfrog.ioBUNDLE_MY__INSTANCE__JFROG__IO).

  3. Point Bundler at Artifactory by updating your Gemfile:

    source 'https://my-instance.jfrog.io/artifactory/api/gems/ruby-virtual'

    Or configure a mirror so the existing source 'https://rubygems.org' line is redirected:

    bundle config mirror.https://rubygems.org https://my-instance.jfrog.io/artifactory/api/gems/ruby-virtual
  4. Install dependencies:

    bundle install
  5. (Optional) If --repo-deploy was set in jf ruby-config, publish a gem with --host set to your Artifactory gems API:

    gem push my-gem-1.0.0.gem --host https://my-instance.jfrog.io/artifactory/api/gems/ruby-local

Important Notes

  • Config-only: There is no jf ruby command. jf ruby-config saves JFrog preferences to .jfrog/projects/ruby.yaml only. Bundler credential and source configuration must be done separately — see After Configuration.
  • Resolution and deployment: Use --repo-resolve for installing gems and --repo-deploy for publishing gems.

CI/CD Example (GitHub Actions)

# .github/workflows/build.yml
steps:
  - uses: actions/checkout@v4

  - name: Setup JFrog CLI
    uses: jfrog/setup-jfrog-cli@v4
    env:
      JF_URL: ${{ vars.JF_URL }}
      JF_ACCESS_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }}

  - name: Setup Ruby
    uses: ruby/setup-ruby@v1
    with:
      ruby-version: '3.2'

  - name: Save JFrog Ruby config
    run: jf ruby-config --server-id-resolve=setup-jfrog-cli-server --repo-resolve=ruby-virtual

  - name: Configure Bundler credentials
    # Inject Artifactory credentials into Bundler so bundle install can authenticate.
    # The env var name is the hostname with dots replaced by double underscores, uppercased.
    # Example for my-instance.jfrog.io → BUNDLE_MY__INSTANCE__JFROG__IO
    env:
      BUNDLE_ARTIFACTORY_HOST: ${{ vars.ARTIFACTORY_HOST }}
      ARTIFACTORY_USER: ${{ vars.ARTIFACTORY_USER }}
      ARTIFACTORY_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }}
    run: bundle config ${BUNDLE_ARTIFACTORY_HOST} ${ARTIFACTORY_USER}:${ARTIFACTORY_TOKEN}

  - name: Install dependencies
    run: bundle install

Store ARTIFACTORY_HOST (for example, my-instance.jfrog.io) and ARTIFACTORY_USER as repository variables. Store the access token as a secret (JF_ACCESS_TOKEN).

Troubleshooting

SymptomCauseFix
bundle install resolves from rubygems.org instead of ArtifactoryBundler gem source or mirror not configuredSet the gem source in your Gemfile or configure a Bundler mirror — see After Configuration
Authentication is required for <host>Bundler credentials not setRun bundle config <host> <user>:<token> or set the BUNDLE_<HOST> environment variable
401 / 403 errors during bundle installInvalid or expired access tokenRe-run jf c add with a fresh access token, then update bundle config credentials
gem push fails with authentication errorGem credentials not configured or --host not specifiedUse gem push my-gem.gem --host https://<host>/artifactory/api/gems/<repo> and ensure credentials are set
gem push fails with "Deploy repository not configured"--repo-deploy not set during jf ruby-configRe-run jf ruby-config with --repo-deploy set

Enable debug logging: export JFROG_CLI_LOG_LEVEL=DEBUG


Related Topics