Home > Interesting > Install Postgres extensions in bitbucket pipeline

Install Postgres extensions in bitbucket pipeline

Problem:
Issue installing postgres extension in bitbucket pipeline

Solution:
Add the following to the bitbucket pipeline
- 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;

Sample:

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

Source:
https://community.atlassian.com/t5/Bitbucket-questions/Install-Postgres-extensions-in-bitbucket-pipeline/qaq-p/591519
https://stackoverflow.com/questions/44242940/install-postgres-extensions-in-bitbucket-pipeline/50109002#50109002

Categories: Interesting
  1. No comments yet.
  1. No trackbacks yet.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.