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.
I supply a patch for this.