Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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?

2 answers

0 votes
edwin Community Leader Dec 23, 2017

Hi,

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

I have same issue. here are images. Postgres service is avialable but can't establish connction.

image: ruby:2.4.0

pipelines:
default:
- step:
caches:
- bundler
services:
- postgres
script: # Modify the commands below to build your repository.
- export DATABASE_URL=postgresql://test_user:test_user_password@localhost/madefor_test
- apt-get update && apt-get install -y build-essential nodejs
- gem install bundler
- bundle install
- apt-get update && apt-get install -y postgresql-client
- RAILS_ENV=test rake db:create rake db:setup
- rake db:test:prepare
- rspec

definitions:
services:
postgres:
image: postgres
environment:
POSTGRES_DB: madefor_test
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_user_password
caches:
bundler: ./vendor

Screen Shot 2018-11-29 at 9.11.39 PM.pngScreen Shot 2018-11-29 at 9.12.43 PM.png

Please use the below one. This is worked for me. 

bitbucket-pipelines.yml
image: ruby:2.6.6

pipelines:
pull-requests:
'**':
- step:
name: RSpec Testcases
caches:
- bundler
script:
- export DATABASE_URL=postgresql://test_user:test_user_password@localhost/pipelines
- gem install bundler
- bundle config set path 'vendor/bundle'
- bundle install
- rails -v
- ruby -v
- psql --version
- RAILS_ENV=test bundle exec rails db:drop db:create db:migrate
- bundle exec rspec
services:
- postgres
definitions:
caches:
bundler: vendor/bundle
services:
postgres:
image: postgres:12.3
variables:
POSTGRES_DB: pipelines
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_user_password

 

Can you post answer if you were able to solve it ?

Thanks

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

366 views 2 10
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you