How do I execute integration tests that need other services, like a database, with Bitbucket Pipelines?

This question is in reference to Atlassian Documentation: Use Docker images as build environments in Bitbucket Pipelines

I have a pretty standard Dropwizard Java web application which depends on a PostgreSQL database. Our maven build runs it's tests by first spinning up a PostgreSQL docker container and then starting the Dropwizard application.

My instinct is to try to continue this approach by rolling a custom environment, but as the building and running of Docker images isn't currently supported ( and this must be a typical use case - what is the intended approach?

2 answers

1 accepted

2 votes
Accepted answer

Funnily enough I'm in the exact same position with an internal project that also requires Postgres (and Postgres specifically) to run its tests.

Right now since you can't run Docker inside Pipelines yet (and therefor can't use docker-compose to pull in a db container), you could create a custom docker image that contains Postgres and use that in your bitbucket-pipelines.yml file:

Pipelines after all, is Docker based and you can provide your own image.

I think this will work - although that approach means it's not really any better than using Bamboo with Docker Agents. Moving to Bitbucket Pipelines is compelling as it's simpler & easier.

As hope it that I can replace my usage of Bamboo (which manages my build and deployment pipeline) with Pipelines, there is also the case to consider where you have a number of microservices, all of which I can spin up locally in Docker containers (the same as spinning up Postgres) for testing purposes - but this constraint means I can't replace my Bamboo integration tests (that I can also run locally simply with `mvn clean verify`).

Is this constraint likely to be permanent? Have I architected a problem for myself? Is there a more appropriate way that Bitbucket Pipelines is supposed to be used?

Here's a list of repositories containing Node.js and Ruby examples of pipelines using Docker images that have databases bundled. You'll also find some documentation on how to simply adapt the Dockerfile to change the Node or Ruby versions:


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

1,955 views 7 10
Read article

Atlassian User Groups

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!

Find my local user group

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

Groups near you