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

Bitbucket Pipelines : interact with Posgresql database



First thing , I read and


For the settings I have no problem but I would to know how to interact with the database ?

For example, load a file of sql insert/create table via psql and then run test


Here is my config file : 

# This is a sample build configuration for Javascript.
# Check our guides at 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: node:6.9.5

    - step:
          # Step 1 : Install yarn with the easy way :
          - curl -o- -L | bash -s -- --version 0.23.4
          # Step 2: Belived
          # PATH variable should change like they said
          - export PATH=$HOME/.yarn/bin:$PATH
          #Allow to use mock controllers for test
          - export CONTROLLERS_FOR_TEST=TRUE
          # Step 3: Install app dependencies
          - yarn install
          #Allow to test app in production context
          - export NODE_ENV=production
          #Allow to specify the JWT TOKEN Signature (and not use OAuth0)
          - export SECRET_SIGNATURE_JWT_TOKEN=pokémon47
          #run the test with mock controllers
          - npm test
          - postgres

# Step 5: Start the test (real database)

      image: postgres:9.3

          #Code not working
          # - docker exec -ti postgres bash
          # prepare PostgreSQL
          # -  psql -U "postgres" -c "CREATE DATABASE custom_db" # create a new database
          # -  psql -U "postgres" -c "CREATE USER custom_user WITH PASSWORD 'custom_pass'" # create a new user : custom_user
          # -  psql -U "postgres" -d "custom_db" -f sql/database_tables.sql # create tables
          # -  psql -U "postgres" -d "custom_db" -f sql/database_grant.sql # give him the credentials
          # -  psql -U "postgres" -d "custom_db" -f sql/test_insert.sql # add basic data inside the database : some parkings and reasons
          # settings for running REST API
          # - export DB_HELPDESK_DB=custom_db
          # - export DB_HELPDESK_USER=custom_user
          # - export DB_HELPDESK_PASS=custom_pass
          # test

1 answer

0 votes

Two ways I can think of to interact with your databases; personally I would write a task in JS to interact with Postgres, so that you can run it with npm eg.

npm run load_db

You can also install the postgresql client from the OS packages. Node 6.9.5 is based on debian, so you can use apt-get to install the postgresql-client package.

apt-get update && apt-get install -qy postgresql-client

Thanks but I cannot start or run any psql command  .... Didn't forgot anything ?


postgres -D /var/lib/postgresql/data
pg_ctl -D /var/lib/postgresql/data -l logfile start


aren't working ...

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Bitbucket

Contest: Share your custom Bitbucket Pipe and win

Announced in this blog, this holiday season we’re celebrating all things CI/CD and between now and the end of 2019 we’ll be showcasing content, use cases, feature announcements and more. One featur...

1,033 views 4 4
Join discussion

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