如何为 python Bitbucket 管道设置 Postgres 数据库模式
How to setup Postgres database schema for python Bitbucket Pipeline
我正在尝试将 bitbucket 管道与我使用 Postgres 数据库的 python 包集成。
为了实现这一点,我正在使用 Postgres 服务,但我无法在 bitbucket-pipelines.yml 中找到任何方法来填充数据库模式。
下面是我的 bitbucket-pipeline.yml 现在我收到错误 "bash: psql: command not found"
image: python:2.7.13
definitions:
services:
postgres:
image: postgres
pipelines:
default:
- step:
caches:
- pip
script:
- python setup.py sdist
services:
- postgres
branches:
master:
- step:
name: Run unit/integration tests
deployment: test
caches:
- pip
script:
- sudo apt-get update && sudo apt-get install -y postgresql-client
- psql -c 'drop database if exists testdb;' -U postgres
- psql -c 'create database testdb;' -U postgres
- python setup.py sdist
- python -m unittest discover tests/
这对我有用(我必须在 apt-get 之前删除 sudos)
image: atlassian/default-image:2
clone:
depth: 5 # include the last five commits
definitions:
services:
postgres:
image: postgres
environment:
POSTGRES_DB: test_annotation
POSTGRES_USER: user
POSTGRES_PASSWORD: password
pipelines:
default:
- step:
caches:
- node
script:
- apt-get update && apt-get install -y postgresql-client
- PGPASSWORD=password psql -h localhost -p 5432 -U user test_annotation;
- chmod 755 ./scripts/create-test-database.sh
- ./scripts/create-test-database.sh
services:
- postgres
确保服务的意图正确,否则数据库将无法启动。
朱利安
我正在尝试将 bitbucket 管道与我使用 Postgres 数据库的 python 包集成。
为了实现这一点,我正在使用 Postgres 服务,但我无法在 bitbucket-pipelines.yml 中找到任何方法来填充数据库模式。
下面是我的 bitbucket-pipeline.yml 现在我收到错误 "bash: psql: command not found"
image: python:2.7.13
definitions:
services:
postgres:
image: postgres
pipelines:
default:
- step:
caches:
- pip
script:
- python setup.py sdist
services:
- postgres
branches:
master:
- step:
name: Run unit/integration tests
deployment: test
caches:
- pip
script:
- sudo apt-get update && sudo apt-get install -y postgresql-client
- psql -c 'drop database if exists testdb;' -U postgres
- psql -c 'create database testdb;' -U postgres
- python setup.py sdist
- python -m unittest discover tests/
这对我有用(我必须在 apt-get 之前删除 sudos)
image: atlassian/default-image:2
clone:
depth: 5 # include the last five commits
definitions:
services:
postgres:
image: postgres
environment:
POSTGRES_DB: test_annotation
POSTGRES_USER: user
POSTGRES_PASSWORD: password
pipelines:
default:
- step:
caches:
- node
script:
- apt-get update && apt-get install -y postgresql-client
- PGPASSWORD=password psql -h localhost -p 5432 -U user test_annotation;
- chmod 755 ./scripts/create-test-database.sh
- ./scripts/create-test-database.sh
services:
- postgres
确保服务的意图正确,否则数据库将无法启动。
朱利安