RSpec pipeline configurations for Ruby on Rails?

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?

4 answers

1 accepted

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

I suggest you troubleshoot with docker locally

 

```

docker run -it  --volume=`pwd`:/repo --workdir="/repo" ruby:2.3.0 /bin/bash

```

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'] %>

 

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

696 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot