Can anyone help me with my rspec configurations for Bitbucket pipeline? How do I set it up?
This is the build failed message.
Screen Shot 2016-10-13 at 9.52.26 AM.png
pipelines configuration file
# This is a sample build configuration for Ruby. # Check our guides at https://confluence.atlassian.com/x/VYk8Lw for more examples. # Only use spaces to indent your .yml configuration. # ----- # You can specify a custom docker image from Docker Hub as your build environment. image: ruby:2.3.0 pipelines: default: - step: script: # Modify the commands below to build your repository. - bundler --version - bundle install - bundle exec rspec
What am I missing out on?
Created the docker image with ruby version 2.3.1 and then my script is as below along with my database.yml and secrets.yml which the Pipeline needs to run tests. After hours of debugging and error after error.
Moving all base configurations to docker is much efficient I suppose.
## bitbucket-pipelines.yml image: aniketrao/ruby-psql pipelines: default: - step: script: # Modify the commands below to build your repository. - /etc/init.d/postgresql start - sudo -u postgres sh -c 'createuser --superuser root & createdb ruby' - sudo -u postgres psql -c "ALTER USER root PASSWORD 'postgres';" - gem install 'pg' - ruby test.rb - apt-get update - apt-get --assume-yes install nodejs - bundle install - mv config/secrets.ci.yml config/secrets.yml - mv config/database.ci.yml config/database.yml - bundle exec rake db:create db:migrate db:schema:load --trace - bundle exec rspec
## database.ci.yml development: adapter: postgresql database: app_test host: localhost pool: 5 username: root password: postgres template: template0
## secrets.ci.yml development: secret_key_base: 6fe52c848a0448c9ddaebd47aad73b85caf99df2f3b70537ae43109e1843159ba432142142f66181195df1f5da49a54abc902bd4c5ffe86697b17d90d05b8fd9
If anyone is stuck, this should help.
Thanks Sten!
Looking online it seems that installing nodejs might solve your issue.
Could you try the following configuration and tell me what you get?
# This is a sample build configuration for Ruby. # Check our guides at https://confluence.atlassian.com/x/VYk8Lw for more examples. # Only use spaces to indent your .yml configuration. # ----- # You can specify a custom docker image from Docker Hub as your build environment. image: ruby:2.3.0 pipelines: default: - step: script: # Modify the commands below to build your repository. - apt-get update - apt-get install nodejs - bundle install - bundle exec rspec
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian has released instructions on how to do this here.
bitbucket-pipelines.yml
image: ruby:2.4.2
pipelines:
default:
- step:
script:
- export DATABASE_URL=postgresql://test_user:test_user_password@localhost/pipelines
- bundle install
- bundle exec rails db:test:prepare
- bundle exec rspec
services:
- postgres
definitions:
services:
postgres:
image: postgres
environment:
POSTGRES_DB: pipelines
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_user_password
config/database.yml
test:
<<: *default
url: <%= ENV['DATABASE_URL'] %>
database: <%= ENV['POSTGRES_DB'] %>
username: <%= ENV['POSTGRES_USER'] %>
password: <%= ENV['POSTGRES_PASSWORD'] %>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.