How do I get a postgres database to run with my pipelines?
You'll need to use services in bitbucket pipelines
In the most simple cases you can connect to localhost:5432 with database 'postgres', user 'postgres' and no password.
pipelines: default: - step: image: node script: - npm install - npm test services: - postgres definitions: services: postgres: image: postgres
If you want to specify a different user or password; the below yaml will create a database server on localhost:5432 with database 'pipelines', user 'test_user' and password 'test_user_password'
pipelines: default: - step: image: node 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
nothing about the psql command ? I would like to use this to prepare the database before I run test ....
Hi I tried following your answer here but seems I'm missing something
image: node:8.1.3 definitions:services: postgres: image: postgresenvironment: POSTGRES_DB: postgres POSTGRES_USER: postgres DATABASE_URL: postgres://postgres@127.0.0.1:5432/testdb pipelines: default: - step: caches: - node - postgres script: # Modify the commands below to build your repository. - psql -c 'drop database if exists testdb;' -U postgres - psql -c 'create database testdb;' -U postgres - npm install - npm run model - npm test services: - postgres
@sergio_pelin Hello again!This issue has been on the back-burner for a while, so I have not come up with a good solution yet.
Hello,
I am also getting the same problem connecting psql. I am using below script for connecting please let me know if i am making any mistake.
image: python:3.7.3definitions: services: postgres: image: postgres environment: POSTGRES_DB: postgres POSTGRES_USER: postgres POSTGRES_PASSWORD: postgrespipelines: default: - step: caches: - pip script: # Modify the commands below to build your repository. - psql -c 'drop database if exists testdb;' -U postgres - psql -c 'create database testdb;' -U postgres - pip install -r requirements.txt - python manage.py makemigrations - python manage.py migrate services: - postgres
I am getting bash: psql: command not found error.
In my case i want to drop the database if already exists and recreate the database.
Please anyone help me to get solution for this.
Thanks in advance.
apt-get install postgresql -y
Is there a solution to this issue? mentioned by @rajeshkanhasoft @patriceharapeti @SebC
Is there a solution to this issue? mentioned by @SebC @patriceharapeti @rajeshkanhasoft
It looks like you're new here. Sign in or register to get started.