I've got the default mysql container running in our Bitbucket Pipeline. When running our db level unit tests, we are getting some errors due to a difference in configuration between the default image being used by Bitbucket's Pipeline and the configuration we run locally and in production.
Out of the 2,500 or so tests, we have 4 actual failures (the code has changed, the tests fail, so this is a good thing at the moment) and an additional 113 errors. The 113 are not present when/if we run the tests locally or in our production environments.
According to the Docker Hub image documentation (https://hub.docker.com/_/mysql/ and see "Using a custom MySQL configuration file") I can see that I could mount my my.cnf file into the container, but I do not know how to do that for the Bitbucket pipeline.
The Bitbucket documentation (https://confluence.atlassian.com/bitbucket/test-with-databases-in-bitbucket-pipelines-856697462.html#TestwithdatabasesinBitbucketPipelines-ConnectingtoMySQL) is a bit vague on this and simply refers to the Docker Hub image documentation (see previous link).
When running the mysql container inside Bitbucket, it makes no mention of loading any config at all.
At this stage, I'm not sure where to go next.
Any help would be appreciated.
Hey @Richard Quadling,
Pipelines Service containers do not support mounting in any volumes at this time, so you have 2 approaches to solving this.
1) Keep using Service Containers, but fork and customise the community mysql image. You could even use a scheduled pipeline to do this for you.
This involves creating a new Dockerfile; eg.
ADD ./mysql-configuration.cnf /etc/mysql/conf.d/
and a pipeline.yml like:
pipelines: custom: # Pipelines that can be scheduled or triggered manually update-mysql-image: # The name that is displayed in the list in the Bitbucket Cloud GUI - step: script:
- docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD # assuming you've created a Dockerhub Account - docker build -t "richard_quadling/mysql:latest" . # assuming the Dockerfile is in the root.
- docker push richard_quadling/mysql:latest # push the image to Dockerhub
2) You can use the Docker service to start the mysql service yourself, mounting the configuration, just as you would locally.
pipelines: default: - step: script:
- docker run --name some-mysql -v $BITBUCKET_CLONE_DIR/mysql/conf.d:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag # Assuming your configuration is located in /mysql/conf.d in your repository
- # the rest of the build
which allows you to manage all aspects of the mysql engine, but requires you to manage the service lifecycle, monitor it, and extract any logs as part of your build process.
Hope that helps,
Announced in this blog, this holiday season we’re celebrating all things CI/CD and between now and the end of 2019 we’ll be showcasing content, use cases, feature announcements and more. One featur...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events