capistranoでデバッグのため、ダミータスクを動かしてみる
概要
デプロイの処理を1個づつ試しながら確認したい場合が多々有ります。 そんな時はCapfileにダミータスクを追加して、そのタスクを直接動かして動作を確認してみましょう。
Capfile
例)GCPのインスタンスリストをコマンドから取得する処理を確かめてみる。
namespace "hoge" do task :moge do run_locally do value = %x[ gcloud compute instances list ] print value,"\n" end end end
実行
怖いので実行するstageはstagingとかが良いと思います。
bundle exec cap staging hoge:moge
結果
コマンドの結果が変数に入って出力できました。
$ bundle exec cap staging hoge:moge DEBUG [9cfe186a] Running /usr/bin/env [ -d /usr/local/rbenv/versions/2.2.3 ] on staging DEBUG [9cfe186a] Command: [ -d /usr/local/rbenv/versions/2.2.3 ] DEBUG [9cfe186a] Finished in 0.296 seconds with exit status 0 (successful). nativeapi-fix nativeapi-newrelic nativeapi-us-201510271040-bpvl nativeapi-us-201510271040-li6e nativeapi-us-201510271040-ptgw nativeapi-us-201510271040-vqhe nativeapi-us-201510271040-vy9v nativeapi-us-201510271040-w804 nativeapi-us-201510271040-wo6y nativeapi-us-201510271040-xqg8 nativeapi-us-201510271040-y0f4 nativeapi-us-201510271040-y5cf nativeapi-us-201510271040-y79p nativeapi-us-201510271040-ye7b nativeapi-us-201510271040-yvoe nativeapi-us-201510271040-zgbc