gitlab-ci can't find config/database.yml, although it's not supposed to exist in my repo
gitlab-ci can't find config/database.yml, although it's not supposed to exist in my repo
I'm trying to create gitlab-ci file for my Rails project.
Here's a part of my .gitlab-ci.yml:
before_script:
- apt-get update -qq && apt-get install -yqq nodejs libmysqlclient-dev
- ruby -v
- which ruby
- gem install bundler --no-ri --no-rdoc
- bundle install --jobs $(nproc) "$FLAGS[@]"
- bundle exec rake db:create db:schema:load
- bundle exec rake db:migrate --quiet
And the error is:
Could not load database configuration. No such file - ["config/database.yml"]
On my local machine and server the files config/database.yml are present.
"config/database.yml" doesn't exist in the repo and isn't supposed too. It's added in gitignore
Only the default config/database.example.yml
exists in my repo. And it doesn't contain the real credentials of my db.
config/database.example.yml
How can I fix it?
1 Answer
1
You have 2 alternatives:
Put on that script to copy the .example.yml
to database.yml
and use the environment variables to set the config:
e.g:
.example.yml
database.yml
production:
username: <%= ENV['DB_USERNAME'] %>
host: <%= ENV['DB_HOST'] %>
etc...
create a script to generate this file for you with data hardcoded or from the environment and call on gitlab-ci.yml
.
gitlab-ci.yml
Documentation is your close friend! docs.gitlab.com/ee/ci/variables/#variables enjoy :D
– Vinicius Amorim De Lima
Aug 17 at 16:49
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
what env. variables will it read in #1 given that it's executed on gitlab? how would I create env variables on gitlab with my db credentials?
– Omanokoto
Aug 17 at 15:50