Skip to content

Add Ruby gems support to JFrog CLI #2992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 30, 2025

Conversation

agrasth
Copy link
Collaborator

@agrasth agrasth commented Jun 4, 2025

  • All tests have passed. If this feature is not already covered by the tests, new tests have been added.
  • The pull request is targeting the dev branch.
  • The code has been validated to compile successfully by running go vet ./....
  • The code has been formatted properly using go fmt ./....

Add Ruby Gems Configuration Support to JFrog CLI

Summary

This PR adds Ruby gems configuration support to the JFrog CLI, enabling developers to configure Ruby projects to use JFrog Artifactory repositories through the jf ruby-config command. The implementation follows established patterns used by other package managers in the JFrog CLI ecosystem and adopts a config-only approach for clean separation of concerns.

Features

Core Functionality

  • Ruby Project Type: Added Ruby to core project type system
  • Configuration Command: New ruby-config (alias: rubyc) command for project setup
  • Repository Management: Configuration file generation for gem repositories
  • Credential Handling: Integration with JFrog CLI's existing authentication system
  • Config-Only Approach: Intentionally excluded from setup command for focused functionality

Commands Added

# Generate Ruby configuration file
jf ruby-config --server-id-resolve myserver --repo-resolve my-gems-repo

# Using alias
jf rubyc --server-id-resolve myserver --repo-resolve my-gems-repo

# Global configuration
jf ruby-config --global --server-id-resolve myserver --repo-resolve my-gems-repo

📁 Files Changed

jfrog-cli-core Repository

  • common/project/projectconfig.go: Added Ruby to ProjectType enum and ProjectTypes slice

jfrog-cli-artifactory Repository

  • artifactory/commands/ruby/ruby.go: New Ruby command package with:
    • Repository URL generation with embedded credentials
    • Gem command execution utilities
    • Configuration management functions
  • go.mod: Updated dependencies for Ruby support

jfrog-cli Repository

  • buildtools/cli.go: Added ruby-config command definition with rubyc alias
  • utils/cliutils/commandsflags.go: Added RubyConfig constant and flag mapping
  • docs/buildtools/rubyconfig/help.go: Command documentation
  • ruby-test/.jfrog/projects/ruby.yaml: Sample configuration file
  • go.mod: Updated with local replace directives for development

Technical Implementation

Architecture

Follows the established three-tier architecture:

  1. Core: Project type definition and configuration system
  2. Artifactory: Repository URL generation and credential management
  3. CLI: User interface and command integration

Configuration Output

Creates .jfrog/projects/ruby.yaml:

version: 1
type: ruby
resolver:
  serverId: myserver
  repo: my-gems-repo

📋 Usage Examples

Basic Configuration Workflow

# Step 1: Configure Ruby project
cd my-ruby-project
jf ruby-config --server-id-resolve production --repo-resolve ruby-gems

# Step 2: Configuration file is created
# .jfrog/projects/ruby.yaml now contains repository settings

# Step 3: Ruby tooling can now use configured repository
# (Future enhancement - actual gem command integration)

Advanced Configuration

# Configure with specific parameters
jf ruby-config \
  --server-id-resolve production \
  --repo-resolve ruby-virtual \
  --project myproject

# Global configuration
jf ruby-config --global \
  --server-id-resolve production \
  --repo-resolve ruby-gems

Help and Documentation

# View command help
jf ruby-config --help
jf rubyc --help

# Command appears in Package Managers category
jf --help

🎯 Integration Points

Command Integration

  • Category: Listed under "Package Managers" in CLI help
  • Flags: Standard resolver flags (--server-id-resolve, --repo-resolve, --global)
  • Alias: rubyc for shorter command syntax
  • Help System: Integrated documentation and bash completion

Configuration System

  • File Format: Standard YAML configuration matching other package managers
  • Location: .jfrog/projects/ruby.yaml (project-specific) or global
  • Structure: Resolver-only configuration (no deployer - config-only approach)

The implementation provides Ruby developers with native JFrog CLI configuration support while maintaining clean separation from interactive setup workflows, completing the package manager configuration matrix for the JFrog CLI.

@agrasth agrasth force-pushed the feature/ruby-gems-support branch from f53b6ce to 36d0eb8 Compare June 16, 2025 07:37
@agrasth agrasth force-pushed the feature/ruby-gems-support branch from 36d0eb8 to 8c796d9 Compare June 16, 2025 07:41
@agrasth agrasth marked this pull request as ready for review June 16, 2025 07:46
@agrasth agrasth requested a review from bhanurp June 16, 2025 07:47
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it has to be part of jfrog-cli repository?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was created just to show the doc of implemented, shouldn't be part of this PR, will remove this from here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this used for tests? If so it should be part of testdata.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, not part of test, will remove this.

@@ -1938,6 +1938,9 @@ var commandFlags = map[string][]string{
Poetry: {
BuildName, BuildNumber, module, Project,
},
RubyConfig: {
global, serverIdResolve, repoResolve,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: why is global flag needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The global flag is needed and is standard across all package manager configurations. It allows users to set configuration:
Global: applies to all projects on the system
Local: applies only to the current project director

This was something maintained across other package managers as well, so i have added it here also

@agrasth agrasth force-pushed the feature/ruby-gems-support branch from 8c796d9 to c5d4de1 Compare June 18, 2025 07:07
go.mod Outdated

// replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250527091824-60a3b4b741aa
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/agrasth/jfrog-cli-core/v2 v2.0.0-20250613074107-730ccf25f2ed
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont see any dependent PR from jfrog-cli-core. Is this required?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it's not needed anymore, I will change this

@@ -1938,6 +1938,9 @@ var commandFlags = map[string][]string{
Poetry: {
BuildName, BuildNumber, module, Project,
},
RubyConfig: {
global, serverIdResolve, serverIdDeploy, repoResolve, repoDeploy,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the flag global flag required?

@agrasth agrasth force-pushed the feature/ruby-gems-support branch from 6dd22a0 to f522da8 Compare June 20, 2025 13:09
@agrasth agrasth added the safe to test Approve running integration tests on a pull request label Jun 20, 2025
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Jun 20, 2025
@agrasth agrasth added the safe to test Approve running integration tests on a pull request label Jun 20, 2025
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Jun 20, 2025
@agrasth agrasth added the safe to test Approve running integration tests on a pull request label Jun 22, 2025
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Jun 22, 2025
@agrasth agrasth force-pushed the feature/ruby-gems-support branch from 269c740 to cbf1476 Compare June 22, 2025 09:04
@agrasth agrasth force-pushed the feature/ruby-gems-support branch from 6e034de to 4d47f88 Compare June 22, 2025 09:30
@agrasth agrasth added the safe to test Approve running integration tests on a pull request label Jun 22, 2025
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Jun 22, 2025
@agrasth agrasth requested a review from bhanurp June 22, 2025 13:27
@agrasth agrasth force-pushed the feature/ruby-gems-support branch from e456155 to f526883 Compare June 24, 2025 09:21
@agrasth agrasth added the safe to test Approve running integration tests on a pull request label Jun 24, 2025
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Jun 24, 2025
@agrasth agrasth force-pushed the feature/ruby-gems-support branch from e39d170 to 9810293 Compare June 24, 2025 10:07
@agrasth agrasth added the safe to test Approve running integration tests on a pull request label Jun 24, 2025
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Jun 24, 2025
@agrasth agrasth added the safe to test Approve running integration tests on a pull request label Jun 30, 2025
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Jun 30, 2025
Resolved conflicts in:
- go.mod: Updated dependency versions to latest from upstream
- go.sum: Updated corresponding checksums

Changes include:
- Updated jfrog-cli-core/v2 to v2.31.1-0.20250629143350-c43614bbffcd
- Updated jfrog-client-go to v1.28.1-0.20250629142537-bb24db402fe1
@agrasth agrasth added the safe to test Approve running integration tests on a pull request label Jun 30, 2025
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Jun 30, 2025
@agrasth agrasth merged commit e4466c8 into jfrog:dev Jun 30, 2025
53 of 66 checks passed
naveenku-jfrog pushed a commit to naveenku-jfrog/jfrog-cli that referenced this pull request Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants