I'm trying to get TeamCity to run the tests on my rails app, but it doesn't see rspec
rspec: command not found
I have created a "Command Line" build step containing the following:
rspec spec/
If I open a terminal at the generated directory, after the build step fails, I can run the tests without any problem, which suggests to me that it's something I'm doing wrong in my TeamCity environment setup (as opposed to the project code).
I believe the problem is that it is failing to switch to the correct version of ruby (I'm using rvm for my ruby version management). To demonstrate the debugging I've done so far, I have changed my "Command Line" build step to be the following:
echo '#do rspec spec/'
rspec spec/
echo '#which rspec?'
echo `which rspec`
echo '#do bundle update'
bundle update
echo '#which ruby are we using?'
echo `which ruby`
echo '#which ruby do we want?'
echo `more Gemfile | grep "ruby "`
echo '#which bundle are we using?'
echo `which bundle`
echo '#available rubies?'
echo `rvm list`
echo '#switch to the right ruby: ruby-2.1.1'
rvm use ruby-2.1.1
echo '#try making rvm a function'
source "$HOME/.rvm/scripts/rvm" && echo "rvm sourced."
echo '#Try switching again'
rvm use ruby-2.1.1
And the resulting output is:
#do rspec spec/
/Users/tom/Desktop/TeamCity/buildAgent/temp/agentTmp/custom_script8352199801919263311: line 2: rspec: command not found
#which rspec?
#do bundle update
Your Ruby version is 2.1.2, but your Gemfile specified 2.1.1
#which ruby are we using?
/Users/tom/.rvm/rubies/ruby-2.1.2/bin/ruby
#which ruby do we want?
ruby "2.1.1"
#which bundle are we using?
/Users/tom/.rvm/gems/ruby-2.1.2@global/bin/bundle
#available rubies?
rvm rubies ruby-2.1.1 [ x86_64 ] =* ruby-2.1.2 [ x86_64 ] # => - current # =* - current && default # Gemfile Gemfile.lock Guardfile Procfile README.rdoc Rakefile app bin config config.ru db docs latest.dump lib log public scripts spec ssl vendor - default
#switch to the right ruby: ruby-2.1.1
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.
#try making rvm a function
rvm sourced.
#Try switching again
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.
Process exited with code 0
I've read dozens of stackoverflow answers and blogs, but still no luck. Any ideas what I can try next? (I haven't found a way to make teamcity use a login shell).