Install Postgres extensions in bitbucket pipeline

So reading the docs I see that setting up Postgres in a bitbucket pipeline is as simple as adding the following:

image: node 
pipelines: 
  default: 
    - step: 
        script: 
          - npm install
          - npm test
        services: 
          - postgres

definitions: 
  services: 
    postgres: 
      image: postgres 
      environment: 
        POSTGRES_DB: 'pipelines' 
        POSTGRES_USER: 'test_user'
        POSTGRES_PASSWORD: 'test_user_password'

What I'd like to know is how I can install some extensions in the database before proceeding further?

2 answers

Hello, I had the same problem and I managed to solve it with this configuration:

 

image: node:8.11.1 # or any image you need

clone:  depth: 1       # include the last commit
definitions:
services:
postgres:
image: postgres environment:
POSTGRES_DB: test POSTGRES_USER: postgres POSTGRES_PASSWORD: your_password pipelines: default: - step:
caches: - node script: - npm install - apt-get update - apt-get -y install postgresql-client - ./bin/utilities/wait-for-it.sh -h localhost -p 5432 -t 30 - PGPASSWORD=your_password psql -h localhost -p 5432 -c "create extension if not exists \"uuid-ossp\"; create extension if not exists pg_trgm;" -U postgres test; - npm test test/drivers/* test/helpers/* test/models/* services: - postgres

My full answer with more explanations can be found here: https://stackoverflow.com/a/50109002/873227

Hey, I had the same problem, and I've answered it here: https://stackoverflow.com/a/50109002/873227

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...

24,969 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