Skip to main content

Working with RubyGems

Publish RubyGems Package

  1. Edit $HOME/.gem/credentials to add a source:

    ---<project path>/~rubygems: Bearer <onedev_access_token>
    <project path>path of a project with package management enabled
    <onedev_access_token>OneDev access token with package write permission over the project
  2. Run below command to prevent the file from reading by others

    chmod 0600 $HOME/.gem/credentials
  3. Push desired gem to the source

    gem push --host<project path>/~rubygems /path/to/<package>-<version>.gem
    <project path>same as above
  4. For CI/CD job, run below to add source via command step

    mkdir -p $HOME/.gem

    # Use job token to tell OneDev the build publishing the package
    # Job secret 'access-token' should be defined in project build setting as an access token with package write permission

    cat << EOF > $HOME/.gem/credentials
    ---<project path>/~rubygems: Bearer @job_token@:@secret:access-token@

    chmod 0600 $HOME/.gem/credentials
    <project path>same as above

Consume Published RubyGems Package

The package detail page contains instructions on how to consume published image.