Pipeline posgres service not working.

I configured my pipeline file like this:

# This is a sample build configuration for Ruby.
# Check our guides at https://confluence.atlassian.com/x/8r-5Mw 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.

pipelines:
default:
- step:
name: Build
image: node:8.6
script: # Modify the commands below to build your repository.
- npm install
- npm run build
- step:
name: Test
caches:
- bundler
image: ruby:2.3.3
script: # Modify the commands below to build your repository.
- apt-get update
- apt-get install -y build-essential libpq-dev nodejs
- cp env.sample.yml config/application.yml
- bundle install
- bundle exec rake db:setup db:migrate RAILS_ENV=test
- bundle exec rspec
services:
- postgres
- redis

definitions:
caches:
bundler: ./vendor
services:
postgres:
image: postgres
restart: always
environment:
POSTGRES_DB: pipelines
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_user_password
redis:
image: redis

 but always get an error when rake db:setup. It said that cannot connect postgres:

+ bundle exec rake db:setup db:migrate RAILS_ENV=testcould not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

but I can see that the postgres is running when building this pipeline. Does anybody meet the same problem?

1 answer

Hi,

This means the database is not setup when rake is executed. Modify so the database is created first.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

27,202 views 26 12
Join discussion

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