Reputation: 18427
How do you push a ruby gem to an artifactory gem repository?
when I try and do a push, I get this error Method not allowed
gem push active_cube-0.0.9.gem --host https://gems.example.com/artifactory/api/gems/gems/ -k rubygems --verbose
GET https://api.rubygems.org/latest_specs.4.8.gz
200 OK
Getting SRV record failed: DNS result has no information for _rubygems._tcp.gems.internal.mx
GET https://gems.example.com/artifactory/api/gems/gems/latest_specs.4.8.gz
200 OK
Pushing gem to https://gems.example.com/artifactory/api/gems/gems/...
POST https://gems.example.com/artifactory/api/gems/gems//api/v1/gems
405 Method Not Allowed
{
"errors" : [ {
"status" : 405,
"message" : "Method Not Allowed"
} ]
}
Upvotes: 2
Views: 2849
Reputation: 2765
The tailing /
in host url is reason for 405 Method Not Allowed.
This log line gives a hint that something went wrong with url composing:
POST https://gems.example.com/artifactory/api/gems/gems//api/v1/gems
See this gems//api
?..
So the command line should supply host without tailing slash:
gem push active_cube-0.0.9.gem --host https://gems.example.com/artifactory/api/gems/gems -k rubygems --verbose
Upvotes: 2
Reputation: 18427
Depending on how the reverse proxy that sits in front of artifactory is configured, you may need to change gems.example.com/artifactory/api/gems/gems/
to gems.example.com/api/gems/gems/
The proper procedure is to
gem push
Use curl to get the api_key and save it to ~/.gem/credentials
. (This will override the contents of ~/.gem/credentials, best to back it up first.
cp ~/.gem/credentials ~/.gem/credentials.back
curl -L gems.example.com/api/gems/gems/api/v1/api_key.yaml \
-u admin:<correct-horse-battery-staple> > ~/.gem/credentials
The contents of ~/.gem/credentials
will look like:
---
:rubygems_api_key: Basic xxxxxxxxxxxxxx
From there, use gem push
. The -k rubygems
option corresponds to the line :rubygems_api_key
in the ~/.gem/credentials file.
gem push active_cube-0.0.9.gem --host https://gems.example.com/api/gems/gems/ -k rubygems --verbose
Upvotes: 0