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
image: node:8.1.3 definitions:
services: postgres: image: postgres
environment: POSTGRES_DB: postgres POSTGRES_USER: postgres DATABASE_URL: postgres://email@example.com: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
I have followed these steps as well, running a node image, and I have the postgres service up and running.
I also have a set of .sql files in my project that defines various tables etc. that I need for integration testing.
In my bitbucket-pipelines.yml file, under the script section, I also have the "psql -U postgres -f \"xyz.sql\"" command to initialise the database.
When Pipelines is running this, I get an error message that "psql: not found"...
If the above example is running, can anyone point me in the direction of how to get this running in my project?
I have tried to do the same setup in my pipeline.
I run a Node image (as parent), has set up the Postgres service, and can see that they are both running in the Pipeline when picked up by BitBucket.
I have an issue running the scripts though. I get the error message "psql: not found".
How to be able to run a given set of scripts, located in my *.sql files in the project, to enable integration tests?
I figure I can create my own Docker image, install Postgres in this image, and then run it from there, but doesn't that defeat the entire purpose of using the services?
Any help is appreciated :)
Badges are a great way to show off community activity, whether you’re a newbie or a Champion.Learn more
Planning and grooming sessions all come with their own sets of rules. Team members meet to estimate stories or other work items, all according to an agreed-upon process. And with every session comes ...
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!
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