Artifactory-如何推红宝石宝石?

时间:2019-06-24 21:55:43

标签: rubygems artifactory

如何将红宝石宝石推入人工宝石库中?

当我尝试进行推送时,出现此错误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"
  } ]
}

2 个答案:

答案 0 :(得分:1)

主机url中结尾的/是405方法不允许的原因。 此日志行提示url编写出现问题:

POST https://gems.example.com/artifactory/api/gems/gems//api/v1/gems

看到这个gems//api吗? 因此,命令行应提供没有斜杠的主机:

gem push active_cube-0.0.9.gem --host https://gems.example.com/artifactory/api/gems/gems -k rubygems --verbose

答案 1 :(得分:0)

取决于如何配置位于工件前面的反向代理,您可能需要将gems.example.com/artifactory/api/gems/gems/更改为gems.example.com/api/gems/gems/

正确的步骤是

  1. 拉动api键
  2. gem push

使用curl获取api_key并将其保存到~/.gem/credentials。 (这将覆盖〜/ .gem / credentials的内容,最好先备份它。

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

~/.gem/credentials的内容如下:

---
:rubygems_api_key: Basic xxxxxxxxxxxxxx

从那里使用gem push-k rubygems选项对应〜/ .gem / credentials文件中的行:rubygems_api_key

gem push active_cube-0.0.9.gem --host https://gems.example.com/api/gems/gems/  -k rubygems --verbose