1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Capistrano 3で複数行のシェルスクリプト的なアレを実行する

Last updated at Posted at 2017-11-15

タイトルの通りですが、Capistrano 3で複数コマンドの組み合わせみたいなのをssh先のサーバ上で実行する方法が分からず微妙に悩んだのでメモ。

結論だけ言えば、ヒアドキュメントに突っ込んでexecuteの引数に渡せばいけました。何を悩んでたんだか。

sample.rake
task 'test' do
  on roles(:all) do
    testcmd = <<-EOS
      echo "This"
      echo
      echo "is"
      echo
      echo "test"
    EOS
    execute testcmd
  end
end
# output sample

$ bundle exec cap stg sample:test

00:00 sample:test
      01 echo "This"; echo; echo "is"; echo; echo "test"
      01 This
      01
      01 is
      01
      01 test
    ✔ 01 sample@host 0.063s
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?