【问题标题】:Deploying with capistrano fails - fatal: HTTP request failed. Requesting github, when set to bitbucket使用 capistrano 部署失败 - 致命:HTTP 请求失败。请求 github,当设置为 bitbucket
【发布时间】:2013-10-09 02:59:22
【问题描述】:

所以我已经使用 Capistrano 进行了相当长的一段时间的部署。一切都很好。最近遇到了一些问题。

过程很简单。我有一个 bitbucket 帐户。我会推送到那里,然后 cap 会获取远程 repo,然后将其推送到远程服务器。这样做时,在使用cap deploy 时,我会被提示两次输入密码;实际上,我什至不知道为什么它两次要求我输入密码(所以也许这可能会有所启发)。尽管如此,它工作了很长时间,然后它随机停止工作。在第二次请求密码时,它现在是 fatal: HTTP request failed

为了让事情变得更加混乱,我查看了这个过程,它在第二个密码提示之后从 github 请求一个 repo...而不是 bitbucket。有一段时间我用过 github,但那是过去的事了。因此,我在 Capfile 和 deploy.rb 中查找了对 github repo 的引用,但没有找到任何对它的引用。

这是在哪里,为什么要求它? 我该如何解决这个问题?

作为参考,这是我的 deploy.rb(当然敏感信息被删除):

set :application, "Application"
set :deploy_to, "/home/user/apps/app"
set :password, "webhostpassword"
set :user, "webhostuser"
set :domain, "webhostip"
set :deploy_via, :remote_cache
set :use_sudo, false 
set :scm, :git
set :repository,  "https://username@bitbucket.org/account/app.git"
set :scm_username, "repousername"
set :scm_passphrase, "repopassword"

ssh_options[:forward_agent] = true

role :web, domain                           # Your HTTP server, Apache/etc
role :app, domain                           # This may be the same as your 'Web' server
role :db,  domain, :primary => true  

default_run_options[:pty] = true

namespace :deploy do
 task :start do ; end
 task :stop do ; end
 task :restart, :roles => :app, :except => { :no_release => true } do
  run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
 end
end

这里是失败的输出:

servers: ["webhostip"]
[webhostip] executing command
** [webhostip :: out] Password:
Password:
** [webhostip :: out]
** [webhostip :: out] error: The requested URL returned error: 403 Forbidden
while accessing https://repo@github.com/repo/app.git/info/refs
**
** fatal: HTTP request failed
←[2;37mcommand finished in 18881ms←[0m

请注意第 6 行和第 7 行,它在请求密码后访问 github(这是第二次使用 cap deploy 时出现密码提示

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 git github capistrano


    【解决方案1】:

    在我的猜测中,如果远程服务器上已经存在 repo,capistrano 将执行 git pull origin <branch> 而不是 git clone <repo url>。因此,它仍在尝试访问 github url。

    您可以通过检查远程服务器上的.git/config 文件来验证这一点。或通过运行git remote -v 命令。如果origin 指向github,则将其更改为bitbucket。然后手动运行git pull origin master 命令以确保它正常工作

    【讨论】:

    • 做了git remote -v。它回复了这个$ git remote -v origin https://jshbrmn@bitbucket.org/2gen/ecosynthetix.git (fetch) origin https://jshbrmn@bitbucket.org/2gen/ecosynthetix.git (push)
    • 您可能还想检查您的本地 .git/config 中是否有 github 引用,因为 capistrano 运行本地 git 命令(从长远来看是一个解决方案,但值得检查)。
    • 在我的远程(webhost)和本地服务器上,来源是相同的(bitbucket)。
    • 你能在你的远程服务器上手动运行cd /home/user/apps/app && git pull origin master吗?
    • 返回了这个Your local changes to the following files would be overwritten by merge:...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-30
    • 1970-01-01
    • 2012-08-15
    • 2021-08-13
    • 2016-09-07
    • 2014-11-19
    • 1970-01-01
    相关资源
    最近更新 更多