使用Capistrano和Travis-CI进行持续部署

时间:2014-01-21 21:49:03

标签: ruby-on-rails ruby capistrano travis-ci

我正在尝试在跟随this Gist之后使用Travis将Rails应用程序部署到VPS,并且我遇到了一些问题。我在服务器上生成加密的ssh密钥,如下所示:

base64 --wrap=0 ~/.ssh/id_rsa > ~/.ssh/id_rsa_base64
ENCRYPTION_FILTER="echo \$(echo \"-\")\$(travis encrypt theodi/uk-postcodes \"\$FILE='\`cat $FILE\`'\" | grep secure:)"
split --bytes=100 --numeric-suffixes --suffix-length=2 --filter="$ENCRYPTION_FILTER" ~/.ssh/id_rsa_base64 id_rsa_

然后,我将生成的加密变量放入我的.travis.yml文件中,然后重新构建私钥before_install,如下所示:

before_install:
  - echo -n $id_rsa_{00..30} >> ~/.ssh/id_rsa_base64
  - base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
  - chmod 600 ~/.ssh/id_rsa
  - echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config

我在成功构建之后运行cap production deploy,如下所示:

after_success:
  - "[ \"$TRAVIS_BRANCH\" == \"master\" ] && bundle exec cap production deploy"

但我仍然没有快乐。我在Travis输出上的错误(来自Capistrano)如下:

INFO [5a729430] Running /usr/bin/env mkdir -p /tmp/uk-postcodes/ on 162.243.77.171
DEBUG [5a729430] Command: ( RAILS_ENV=production /usr/bin/env mkdir -p /tmp/uk-postcodes/ )
cap aborted!
deploy
/home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh.rb:215:in `start'
/home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/connection_pool.rb:25:in `create_or_reuse_connection'
/home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:173:in `ssh'
/home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:126:in `block in _execute'
/home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `tap'
/home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `_execute'
/home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:66:in `execute'
/home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/rvm1-capistrano3-1.1.1/lib/rvm1/tasks/capistrano3.rake:5:in `block (3 levels) in <top (required)>'
/home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `run'
/home/travis/build/theodi/uk-postcodes/vendor/bundle/ruby/2.0.0/gems/sshkit-1.3.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'

我还在我的服务器上添加auth.log,我看到了错误error: key_read: uudecode

我可能会出错的任何想法? (第一步涉及一定数量的货物结果,但我想我明白发生了什么)

1 个答案:

答案 0 :(得分:1)

travis gem(CLI工具)有一些可以简化编码的更新。 我在博客文章https://cowbell-labs.com/2014-03-06-capistrano-deploys-from-travis.html

中描述了一种通过Capistrano从Travis部署应用程序的方法
相关问题