LoginSignup
0
0

More than 5 years have passed since last update.

capistrano の2系で、git の特定のブランチ名でデプロイできない

Posted at

状況

  • Capistrano 2.10 〜 2.15.9 を使っている
  • Capistrano 2系の、 multistage 拡張機能を使っている
  • cap コマンドを実行するときの、ブランチ名などを指定するためのコマンド引数に -T --tasks -e --explain のいずれかが入っている

️ 事象

デプロイが進まなくなる。エラーが起きる。

ログとしては

  * 2016-05-25 20:38:19 executing `foo_bar_stage'
  * 2016-05-25 20:38:19 executing `foo_bar_stage'

こんな感じで、 stage 名が二回出てくる。

️ 原因

コード中に

      find_and_execute_task(env) if ARGV.any?{ |option| option =~ /-T|--tasks|-e|--explain/ }

とある。 https://github.com/capistrano/capistrano/blob/v2.15.9/lib/capistrano/ext/multistage.rb#L30

multistage は、あるメソッドに二回到達する(そして、一回目と二回目で引数を変わっていて、違う分岐に進む)ような構造になっているが、この if 文によってそれが間違った分岐に入る。ように見えます。

ちゃんとは調べてません。調べる意義も感じませんでした。

対応策

cap のバージョンをあげ ... られる状況の人は、たぶんこんな問題にはたどり着かないと思うので、引数の名前とかを、上記 NG ワードを含めないように変えるのがいいと思います。

雑感

この記事が、誰かにお役に立てば嬉しいです

0
0
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
0
0