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

dhardiker_adaptavist July 29, 2016

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 (https://confluence.atlassian.com/bitbucket/limitations-of-bitbucket-pipelines-beta-827106051.html) and this must be a typical use case - what is the intended approach?

2 answers

1 accepted

2 votes
Answer accepted
evzijst
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 29, 2016

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:

https://confluence.atlassian.com/display/BITBUCKET/Configure+bitbucket-pipelines.yml#Configurebitbucket-pipelines.yml-ci_image

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

dhardiker_adaptavist July 29, 2016

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?

1 vote
Sten Pittet
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 5, 2016

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
TAGS
AUG Leaders

Atlassian Community Events