Is it possible to install gem from private gitlab host from Heroku

笑着哭i 提交于 2019-12-24 01:21:55

问题


I have a private gitlab host, which host private codes and project, and I host my app in heroku, in that heroku app, we use Gemfile to manage dependence of that heroku app, one of those dependence is from private gitlab host. so my Gemfile is something like this:

gem 'my_greate_gem', '0.0.1', :git => "http://myprivate_gitlab_host/private_gems/my_great_gem.git"

It's seems there's not any tutorial mentions about using private gitlab host to hosting gem in Heroku, but I really don't want to use gemfury. Is there any possible solution for this?


回答1:


Without using Gemfury you would have to pass a username and password in the URL of the gem dependency

 gem 'my_greate_gem', '0.0.1', :git => "http://<username>:<password>@myprivate_gitlab_host/private_gems/my_great_gem.git"



回答2:


The other answer didn't work for me. Also, I prefer a method that allows me to keep credentials out of source. I put the following in my gemfile:

gem 'mygem', git: "https://oauth2:#{ENV['GITLAB_TOKEN']}@gitlab.com/mygroup/mygem.git"

The gitlab token I created has API access. This works for me on heroku if I manually set the GITLAB_TOKEN in the environment variables in settings.

Hope that helps.



来源:https://stackoverflow.com/questions/22601829/is-it-possible-to-install-gem-from-private-gitlab-host-from-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!