I went through a few iterations of running builds via shell commands in Jenkins. Once I added a remote node things didn’t work quite the same as on master. I learned that Jenkins creates a .sh file and executes it with -xe, so we can change the interpreter like this.
#!/bin/bash
source ~/.bash_profile
bundle install
bundle exec ...
This loads RVM from .bash_profile. You can add an rvm use in there if you are building with multiple versions of Ruby.