2017-08-14 4 views
1

Jenkinsfileでルビー仕様のテストを実行しようとしています。
このコードを実行するときしかし、私が問題に実行している:Jenkinsで実行しているときにgem rspec-core(> = 0.a)(Gem :: GemNotFoundException)が見つかりません

sh 'rspec spec/unit/test_spec.rb' 

これはエラーです:

/home/user/.rvm/rubies/ruby-2.4.0/lib/ruby/site_ruby/2.4.0/rubygems.rb:271:in 'find_spec_for_exe': can't find gem rake (>= 0.a) (Gem::GemNotFoundException) from /home/user/.rvm/rubies/ruby-2.4.0/lib/ruby/site_ruby/2.4.0/rubygems.rb:299:in 'activate_bin_path' from /home/user/.rvm/gems/[email protected]/bin/rake:23:in '' from /home/user/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in eval' from /home/user/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in ''

私はEC2インスタンス上でジェンキンスを実行しています。仕様テストを実行する前にバンドルをインストールするので、gem rspec-coreが確実にインストールされます。私はまた、Jenkinsの代わりにインスタンスそのものと同じテストを実行しています。 私はジェンキンス上gem which rspecを実行すると、それは私に、このエラー与える:

ERROR: Can't find ruby library file or shared library rspec

をしかし、私は、インスタンス上でそれを実行すると、それがグローバルgemsetを使用している両
/home/user/.rvm/gems/[email protected]/gems/rspec-3.6.0/lib/rspec.rb

を返します。 何が問題なのでしょうか?

答えて

1

私はそれではなく、はるかにクリーンかつ明確である個々のテスト自体を、実行しているのすくいファイルを使用しています

sh 'bundle exec rake spec:unit'

を使用してスペックテストを実行するために管理。すべてのユニットテストを実行します

namespace :spec do 
    RSpec::Core::RakeTask.new(:unit) do |t|` 
     t.pattern = 'spec/unit/**/*_spec.rb' 
    end 
end 

task default: ['spec:unit'] 

これはrakefileがどのように見えるかです。

+0

Jenkinsを使用していないにもかかわらずこれは役に立ちました。なぜなら、あなたの答えは '' bundle exec'''を使うことだったからです。 –

関連する問題