0

我有一个 Jenkins CI 服务器,当我运行以下构建脚本时出现错误:

rdoc spec

这是错误:

/usr/bin/ruby1.9.1 -S rspec spec/requests/home_spec.rb
/home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/bundler-1.0.21/lib/bundler/spec_set.rb:88:in `block in materialize': Could not find json-1.6.5 in any of the sources (Bundler::GemNotFound)
    from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/bundler-1.0.21/lib/bundler/spec_set.rb:82:in `map!'
    from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/bundler-1.0.21/lib/bundler/spec_set.rb:82:in `materialize'
    from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/bundler-1.0.21/lib/bundler/definition.rb:90:in `specs'
    from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/bundler-1.0.21/lib/bundler/definition.rb:135:in `specs_for'
    from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/bundler-1.0.21/lib/bundler/runtime.rb:11:in `setup'
    from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/bundler-1.0.21/lib/bundler.rb:117:in `setup'
    from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
    from /var/lib/jenkins/jobs/App1/workspace/config/boot.rb:10:in `<top (required)>'
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from /var/lib/jenkins/jobs/App1/workspace/spec/spec_helper.rb:11:in `<top (required)>'
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from /var/lib/jenkins/jobs/App1/workspace/spec/requests/home_spec.rb:1:in `<top (required)>'
    from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load'
    from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `block in load_spec_files'
    from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `map'
    from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load_spec_files'
    from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:22:in `run'
    from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
    from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
    from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `block in autorun'
rake aborted!

这是我的 Rakefile:

require 'rdoc/task'
require 'rspec/core/rake_task'

desc 'Generate test result'
RSpec::Core::RakeTask.new(:spec) do |t|
  t.pattern = 'spec/*/*_spec.rb'
end

这是我的 Gemfile:

source :rubygems

# Required gems
gem 'sinatra', '>= 1.3.2'
gem 'rdoc', '>= 3.12'
gem 'rake'
gem 'json', '>= 1.6.5'

group :test do
  gem 'rspec', '>= 2.9.0'
  gem 'rack-test'
  gem 'simplecov', '>= 0.6.1', require: false
end

我没有任何想法。请帮我。我将 Ruby 1.9.3 与 RVM 一起使用。

谢谢你的每一个建议。对不起英语不好:)

4

1 回答 1

1

可能原因是 Jenkins 运行构建的环境与运行构建的环境不同。

通常差异是由为您设置但不是为 Jenkins 设置的环境变量引起的

您可以通过运行命令来检查您的环境变量env。您可以在 Manage Jenkins -> System Information 中查看 Jenkins 的环境。

如果需要设置一些环境变量,可以在 Manage Jenkins -> Configure System 中进行。

于 2012-04-12T18:31:03.473 回答