Working with RubyGems
Publish RubyGems Package
-
Edit
$HOME/.gem/credentialsto add a source:---https://onedev.example.com/<project path>/~rubygems: Bearer <onedev_access_token>Param Explanation <project path> path of a project with package management enabled <onedev_access_token> OneDev access token with package write permission over the project -
Run below command to prevent the file from reading by others
chmod 0600 $HOME/.gem/credentials -
Push desired gem to the source
gem push --host https://onedev.example.com/<project path>/~rubygems /path/to/<package>-<version>.gemParam Explanation <project path> same as above -
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 permissioncat << EOF > $HOME/.gem/credentials---https://onedev.example.com/<project path>/~rubygems: Bearer @job_token@:@secret:access-token@EOFchmod 0600 $HOME/.gem/credentialsgem build <package>.gemspecgem push --host https://onedev.example.com/<project-path>/~rubygems <package>-<version>.gemParam Explanation <project path> same as above
Consume Published RubyGems Package
Open the package detail page for installation instructions. Use an account or token with package read permission and install from the OneDev source:
gem install <package> --version <version> --clear-sources --source https://onedev.example.com/<project-path>/~rubygems --no-document
Configure download authentication as shown on the package detail page. The bearer credential in $HOME/.gem/credentials authenticates gem push; package installation may need separate source authentication. Keep credentials out of source control.
