Postgresql 在bitbucket管道中安装Postgres扩展
因此,我为我的python应用程序设置了一个Postgresql 在bitbucket管道中安装Postgres扩展,postgresql,bitbucket,bitbucket-pipelines,Postgresql,Bitbucket,Bitbucket Pipelines,因此,我为我的python应用程序设置了一个bitbucket pipelines.yml。它需要一个postgres数据库,因此我遵循了此处的教程(),该教程引导我使用以下配置: image: node pipelines: default: - step: script: - npm install - npm test services: - postgres definitions: services:
bitbucket pipelines.yml
。它需要一个postgres数据库,因此我遵循了此处的教程(),该教程引导我使用以下配置:
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'
我需要一些特定的扩展在我的数据库,我如何才能添加这些。我试图在安装它们的脚本中添加一个额外的映像,但此时postgres似乎没有启动和运行。您需要基于postgres创建自己的映像,然后将其推送到存储库并在管道中使用
definitions:
services:
postgres:
image: your_custom_image_based_on_postgres
environment:
POSTGRES_DB: 'pipelines'
POSTGRES_USER: 'test_user'
POSTGRES_PASSWORD: 'test_user_password'
您还可以在中找到符合您要求的图像,这对我来说很有用,无需构建自己的图像(我为postgres添加了2个扩展):
等待。sh
确保postgres已准备好运行,您可以在此处找到它:
然后,我运行psql在测试数据库中创建扩展。这里请注意我在运行之前设置的变量PGPASSWORD
,并且我使用-h
和-p
参数连接到正在运行的postgres实例(否则它将尝试使用unix套接字执行此操作,这似乎不起作用)
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