jenkinsで実行したらジョブがエラーになったので調べました。
前提として、rubocopで警告が1個以上出る状態で実行しています。
jenkinsのバージョンは1.599-1.1
jenkinsのジョブでシェルの実行に以下を追加してジョブを実行する
bundle exec rubocop --debug --rails --no-color --require rubocop/formatter/checkstyle_formatter --format RuboCop::Formatter::CheckstyleFormatter --out test/reports/checkstyle.xml実行してみたらこんな感じでfailureになりました。
12:32:28 + bundle exec rubocop --debug --rails --no-color --require rubocop/formatter/checkstyle_formatter --format RuboCop::Formatter::CheckstyleFormatter --out test/reports/checkstyle.xml 12:32:29 warning: parser/current is loading parser/ruby21, which recognizes 12:32:29 warning: 2.1.5-compliant syntax, but you are running 2.1.4. 12:32:36 For /var/lib/jenkins/jobs/test/workspace: configuration from /var/lib/jenkins/jobs/test/workspace/.rubocop.yml 12:32:36 Inheriting configuration from /var/lib/jenkins/jobs/test/workspace/.rubocop_todo.yml 12:32:36 Default configuration from /var/lib/jenkins/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rubocop-0.28.0/config/default.yml 12:32:36 Inheriting configuration from /var/lib/jenkins/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rubocop-0.28.0/config/enabled.yml 12:32:36 Inheriting configuration from /var/lib/jenkins/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rubocop-0.28.0/config/disabled.yml 12:32:36 Scanning /var/lib/jenkins/jobs/test/workspace/Gemfile 12:32:36 Scanning /var/lib/jenkins/jobs/test/workspace/Rakefile 12:32:36 Scanning /var/lib/jenkins/jobs/test/workspace/Capfile ・・・・ 12:32:53 Finished in 23.879888448 seconds 12:32:53 Build step 'シェルの実行' marked build as failure
シェルの内容を最後に必ずexit 0を返す以下に変更してみたが状況は変わらず。。
bundle exec rubocop --debug --rails --no-color --require rubocop/formatter/checkstyle_formatter --format RuboCop::Formatter::CheckstyleFormatter --out test/reports/checkstyle.xml exit 0
jenkinsについて調べてみると、jenkinsのシェルの実行は
/bin/sh -xe
で実行されているので、0でない終了コードが出た時点でスクリプトが終了するらしい。
シェルの内容を以下に変更してみる
/bin/sh -x bundle exec rubocop --debug --rails --no-color --require rubocop/formatter/checkstyle_formatter --format RuboCop::Formatter::CheckstyleFormatter --out test/reports/checkstyle.xml exit 0
再度実行してみると無事に成功しました。
12:44:42 + bundle exec rubocop --debug --rails --no-color --require rubocop/formatter/checkstyle_formatter --format RuboCop::Formatter::CheckstyleFormatter --out test/reports/checkstyle.xml 12:44:43 warning: parser/current is loading parser/ruby21, which recognizes 12:44:43 warning: 2.1.5-compliant syntax, but you are running 2.1.4. 12:44:50 For /var/lib/jenkins/jobs/test/workspace: configuration from /var/lib/jenkins/jobs/test/workspace/.rubocop.yml 12:44:50 Inheriting configuration from /var/lib/jenkins/jobs/test/workspace/.rubocop_todo.yml 12:44:50 Default configuration from /var/lib/jenkins/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rubocop-0.28.0/config/default.yml 12:44:50 Inheriting configuration from /var/lib/jenkins/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rubocop-0.28.0/config/enabled.yml 12:44:50 Inheriting configuration from /var/lib/jenkins/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rubocop-0.28.0/config/disabled.yml 12:44:50 Scanning /var/lib/jenkins/jobs/test/workspace/Gemfile 12:44:50 Scanning /var/lib/jenkins/jobs/test/workspace/Rakefile 12:44:50 Scanning /var/lib/jenkins/jobs/test/workspace/Capfile ・・・ 12:45:07 Finished in 23.688404726 seconds 12:45:07 + exit 0
参考URL
http://qiita.com/mechamogera/items/f689b95670127d5bf046
0 件のコメント:
コメントを投稿