2014-04-15 20 views
1

我一直在爲這個問題苦苦掙扎了很長一段時間......並且我無法弄清楚在連續集成服務器發生連接時如何提高錯誤集成服務器(Jenkins)。在持續集成服務器(Jenkins)中配置環境文件以引發錯誤

這是我目前的環境文件的例子:

SomeApp::Application.configure do 
    config.cache_classes        = false 
    config.serve_static_assets      = true 
    config.static_cache_control      = "public, max-age=3600" 
    config.whiny_nils         = true 
    config.consider_all_requests_local    = true 
    config.action_controller.perform_caching   = false 
    config.action_dispatch.show_exceptions   = false 
    config.action_controller.allow_forgery_protection = false 
    config.action_mailer.delivery_method    = :test 
    config.active_support.deprecation     = :stderr 
    config.assets.allow_debugging      = true 
end 

我想重現相同的環境中生產,但在這種環境下我會提高而不是重定向到錯誤500分之404/ 501等

但有了這個配置,當詹金斯在我的應用程序捕獲了一個錯誤,這裏是輸出:

PASS (0:00:17.313) page 022/621 '/some/path?filter=with results' 
FAIL (0:00:17.798) page 023/621 '/some/other/path' 
    <body>You are being <a href="http://www.example.com/500.html">redirected</a>.</body> 
@ test/integration/access_all_pages_test.rb:411:in `assert_response' 
    test/integration/access_all_pages_test.rb:427:in `block (2 levels) in <class:AccessAllPagesTest>' 
    /var/lib/jenkins/.rvm/gems/[email protected]/bundler/gems/rails-dbd26e92a7b9/activesupport/lib/active_support/testing/setup_and_teardown.rb:36:in `block in run' 
    /var/lib/jenkins/.rvm/gems/[email protected]/bundler/gems/rails-dbd26e92a7b9/activesupport/lib/active_support/callbacks.rb:447:in `_run__2667904121553047838__setup__2490215204465429087__callbacks' 
    /var/lib/jenkins/.rvm/gems/[email protected]/bundler/gems/rails-dbd26e92a7b9/activesupport/lib/active_support/callbacks.rb:405:in `__run_callback' 
    /var/lib/jenkins/.rvm/gems/[email protected]/bundler/gems/rails-dbd26e92a7b9/activesupport/lib/active_support/callbacks.rb:385:in `_run_setup_callbacks' 
    /var/lib/jenkins/.rvm/gems/[email protected]/bundler/gems/rails-dbd26e92a7b9/activesupport/lib/active_support/callbacks.rb:81:in `run_callbacks' 
    /var/lib/jenkins/.rvm/gems/[email protected]/bundler/gems/rails-dbd26e92a7b9/activesupport/lib/active_support/testing/setup_and_teardown.rb:35:in `run' 

而不是公頃詠完整的堆棧跟蹤,就像我會在我的開發環境得到...

我發現這部分的文檔中:

ActionDispatch :: ShowExceptions搶救由 應用程序返回的任何異常並呈現漂亮如果請求是本地 或config.consider_all_requests_local設置爲true,則顯示異常頁面。如果 config.action_dispatch.show_exceptions設置爲false,則無論如何都會引發異常 。

但它沒有幫助。

有沒有人知道如何配置?

回答

0

嗯...那是我的錯,我有:

class ApplicationController < ActionController::Base 
    rescue_from Exception, with: :handle_error 

    def handle_error(exception, perform_redirect = true) 
    # ... 
    raise exception if Rails.env.development? || Rails.env.test? 
    end 

更改爲:

raise exception unless Rails.env.production? 

這使得更多的意義:如果環境不生產=>引發錯誤。

(我在詹金斯使用的RAILS_ENV不是test,但幾個作業需要幾個環境)

相關問題