Hi.

I just introduced an AR observer into my project. That made my CI
builds fail.

The error in the build log was this:
------------------------------------------------------------
home/cruise/.cruise/projects/pegasus/work cruise$ ruby1.8 -e "require 
'rubygems' rescue nil; require 'rake'; load 
'/home/cruise/cruisecontrol-1.4.0/tasks/cc_build.rake'; ARGV << '--nosearch' << 
'cc:build'; Rake.application.run; ARGV.clear"
rake aborted!
FATAL:  password authentication failed for user "pegasus_dev"
------------------------------------------------------------

pegasus_dev is the name of the database in my development
environment. On my CI machine (where cc.rb runs), there is no
DB nor DB user for development environment.

I confirmed that when I outcommented my configuration line enabling my
observer like this in config/environment.rb
------------------------------------------------------------
  # config.active_record.observers = :order_state_observer
------------------------------------------------------------
then things started to work again.

But why the sudden was CC.rb sudenly starting to use my development
environment?

So I got curious: I went to my CI machine
~/.cruise/projects/pegasus/work and ran (adding the --trace argument)
ruby1.8 --debug -e "require 'rubygems' rescue nil; require 'rake'; load 
'/home/cruise/cruisecontrol-1.4.0/tasks/cc_build.rake'; ARGV << '--nosearch' << 
'--trace' << 'cc:build'; Rake.application.run; ARGV.clear" 2> ~/trace.err 1> 
~/trace.out

That showed that when configuring observer, the ENV['RAILS_ENV'] =
'test' statement in cc_build.rake:38 is not propagated properly to the
project rake task db:test:purge, it has to be set on a higher level.

So I added the argument 'RAILS_ENV=test' to the build command, and things work.

Here is a patch the the build model.

--- cruisecontrolrb/app/models/build.rb.org	2010-03-08 16:46:41.000000000 +0100
+++ cruisecontrolrb/app/models/build.rb	2010-03-08 16:47:14.000000000 +0100
@@ -167,7 +167,7 @@
     # --nosearch flag here prevents CC.rb from building itself when a project has no Rakefile
     # ARGV.clear at the end prevents Test::Unit's AutoRunner from doing anything silly, like trying to require 'cc:rb'
     # Some people saw it happening.
-    %{#{Platform.interpreter} -e "require 'rubygems' rescue nil; require 'rake'; load '#{ABSOLUTE_RAILS_ROOT}/tasks/cc_build.rake'; ARGV << '--nosearch'#{CruiseControl::Log.verbose? ? " << '--trace'" : ""} << 'cc:build'; Rake.application.run; ARGV.clear"}
+    %{#{Platform.interpreter} -e "require 'rubygems' rescue nil; require 'rake'; load '#{ABSOLUTE_RAILS_ROOT}/tasks/cc_build.rake'; ARGV << 'RAILS_ENV=test' << '--nosearch'#{CruiseControl::Log.verbose? ? " << '--trace'" : ""} << 'cc:build'; Rake.application.run; ARGV.clear"}
   end
 
   def in_clean_environment_on_local_copy(&block)
I have created ticket #278

Jarl


-- 
Jarl Friis
Gavia Technologies ApS
Omøgade 8, 2.sal
2100 København Ø.
Denmark
Phone:  +45 26 13 20 90
E-mail: j...@gavia.dk
LinkedIn: www.linkedin.com/in/jarlfriis
_______________________________________________
Cruisecontrolrb-users mailing list
Cruisecontrolrb-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/cruisecontrolrb-users

Reply via email to