简体   繁体   English

使用capistrano部署失败-致命:HTTP请求失败。 在设置为bitbucket时请求github

[英]Deploying with capistrano fails - fatal: HTTP request failed. Requesting github, when set to bitbucket

So I've been deploying with Capistrano for quite some time now. 因此,我已经在Capistrano上部署了一段时间。 Everything was good. 一切都很好。 Recently I ran into some issues. 最近,我遇到了一些问题。

The process was simple. 这个过程很简单。 I have a bitbucket account. 我有一个bitbucket帐户。 I would push there and then cap would take the remote repo and then push it to the remote server. 我将推送到那里,然后用cap提取远程仓库,然后将其推送到远程服务器。 In doing so, upon using cap deploy I would be prompted twice for password; 这样,在使用cap deploy ,将提示我两次输入密码; and actually, I don't even really know why it asked me for a password twice ( so perhaps this could have some light shed on it ). 实际上,我什至不知道为什么它两次要求我输入密码( 所以也许可以对此有所了解 )。 Nonetheless, it worked for a long time, then it randomly stopped working. 尽管如此,它工作了很长时间,然后随机停止了工作。 Upon requesting a password the second time, it was now saying fatal: HTTP request failed . 在第二次请求密码时,现在说的是fatal: HTTP request failed

To make matters even more confusing, I looked over the process and it's requesting a repo from a github after the second password prompt...and not bitbucket . 让事情变得更加混乱的是,我查看了整个过程,它在第二个密码提示之后而不是bitbucket上github请求回购。 There was a time when I used github, but that was in the past. 曾经有一段时间我使用github,但这是过去的事情。 So, I looked for a reference to the github repo in my Capfile and my deploy.rb, not finding any reference to it. 因此,我在Capfile和deploy.rb中寻找了对github存储库的引用,但没有找到任何引用。

Where is this and why is it requesting it? 这在哪里,为什么要提出要求? How can I fix this? 我怎样才能解决这个问题?

For reference, here is my deploy.rb (with sensitive info taken out of course): 作为参考,这是我的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

and here the output where it is failing: 这里是失败的输出:

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

Notice line 6 and 7 where it is accessing github after it asks for the password (this is the second time a password prompt comes up upon using cap deploy 注意第6行和第7行在询问密码后正在访问github的位置(这是使用cap deploy时第二次出现密码提示

In my guess, capistrano will do a git pull origin <branch> instead of git clone <repo url> if the repo already exists on the remote server. 以我的猜测,如果远程服务器上已经存在回购,则capistrano将执行git pull origin <branch>而不是git clone <repo url> Hence, it is still trying to hit github url. 因此,它仍在尝试访问github url。

You can verify this by checking the .git/config file on your remote server. 您可以通过检查远程服务器上的.git/config文件来验证这一点。 or by running git remote -v command. 或通过运行git remote -v命令。 If origin is pointing to github , change that to bitbucket . 如果origin指向githubbitbucket更改为bitbucket Then manually run a git pull origin master command to ensure it is working 然后手动运行git pull origin master命令以确保其正常工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM