The old question is, and whether this will work for your application, I can not be sure, since you did not specify the details of your application. However, I wanted to add the way that I did this in our test suite of Rails applications.
The configuration of our application database.yml ( database.yml ) is not in the source repository. Instead, he lives in /var/lib/configs/uniquing_database.yml on the virtual machine that runs our Jenkins instance.
One of the steps in our build process is to copy this configuration file to the project workspace:
cp /var/lib/jenkins/configs/myapp_unique_database.yml config/database.yml
and this configuration takes the workspace and number information open to the Jenkins environment to create a unique database for this job and specific execution:
test: adapter: postgresql encoding: unicode host: 127.0.0.1 port: 5432 database: myapp_test<%= ENV['JOB_NAME'].split('/').last %><%= ENV['BUILD_NUMBER'] %>
The rest of our assembly continues without any knowledge or concern that it works in a separate database. Finally, at the end of our assembly, we will definitely delete this database so that we do not have a bunch of test databases polluting the file system:
RAILS_ENV=test bundle exec rake db:drop
Yoopergeek Mar 08 '16 at 3:02 2016-03-08 03:02
source share