如何使用GitHub通过Capistrano和Jenkins部署Ruby on Rails应用程序

时间:2018-06-21 07:43:39

标签: ruby-on-rails ruby-on-rails-3 jenkins capistrano

我是Jenkin的新手,我需要使用jenkin部署Ruby on Rails应用程序。我正在使用Capistrano任务将Rails应用程序部署到ec2服务器。

我们的开发团队正在维护Jenkin服务器,他们创建了一个凭证来从Github获取最新的仓库。我不确定是否必须使用他们的凭证,或者可以,我该如何使用他们的凭证

deploy@localhost:~/rails_project (staging)$ bundle exec cap staging deploy
* executing `staging'
  triggering start callbacks for `deploy'
* executing `multistage:ensure'
* executing `deploy'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
  updating the cached checkout on all servers
  executing locally: "git ls-remote git@github.com:Private-Repo/rails_project.git staging"
  command finished in 4387ms
* executing "if [ -d /home/ec2-user/rails_project/shared/cached-copy ]; then cd /home/ec2-user/rails_project/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 2349f182417bc5932c7cdefcfeecac12b98ade28 && git clean -q -d -x -f; else git clone -q git@github.com:Private-Repo/rails_project.git /home/ec2-user/rails_project/shared/cached-copy && cd /home/ec2-user/rails_project/shared/cached-copy && git checkout -q -b deploy 2349f182417bc5932c7cdefcfeecac12b98ade28; fi"
servers: ["111.111.111.111"]
* establishing connection to gateway `"bastion_user@bastion.server.com"'
* Creating gateway using bastion_user@bastion.server.com
* establishing connection to `111.111.111.111' via gateway
[111.111.111.111] executing command
** [111.111.111.111 :: out] Failed to add the RSA host key for IP address '192.xx.xxx.xxx' to the list of known hosts (/home/ec2-user/.ssh/known_hosts).
** [111.111.111.111 :: out] Permission denied (publickey).
** [111.111.111.111 :: out] fatal: Could not read from remote repository.
** 
** Please make sure you have the correct access rights
** and the repository exists.
command finished in 1925ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/ec2-user/rails_project/releases/20180621070926; true"
servers: ["111.111.111.111"]
[111.111.111.111] executing command
command finished in 1422ms
failed: "env RAILS_ENV=staging sh -c 'if [ -d /home/ec2-user/rails_project/shared/cached-copy ]; then cd /home/ec2-user/rails_project/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 2349f182417bc5932c7cdefcfeecac12b98ade28 && git clean -q -d -x -f; else git clone -q git@github.com:Private-Repo/rails_project.git /home/ec2-user/rails_project/shared/cached-copy && cd /home/ec2-user/rails_project/shared/cached-copy && git checkout -q -b deploy 2349f182417bc5932c7cdefcfeecac12b98ade28; fi'" on 111.111.111.111

但是Jenkin使用的是凭证,它可以从Github获取回购,我如何将Github,Capistrano和Jenkin与Github密钥一起使用。如果需要更多信息,请询问,谢谢

0 个答案:

没有答案