Running tests with Docker and Jenkins - Test Result Running tests with Docker and Jenkins - Test Result jenkins jenkins

Running tests with Docker and Jenkins - Test Result


Jenkins uses the exit status of the process to judge success or failure.

docker-compose up is designed to orchestrate many containers. When you are dealing with multiple services/containers there is a bit of a grey area as to what constitutes success and failure. All that docker-compose reports on exit is that the docker-compose command completed successfully, not that all containers it ran are ok.

docker-compose run <service> <command> will run a single command for a service and return that commands exit status.

If you rely on multiple services/containers for the tests, then have docker-compose up only bring up the required services. Then run docker-compose run rubyservice rspec afterwards for your tests.

Compose seperation

If you want to keep the tests seperate from the app containers, create a second docker-compose-test.yml file that contains a service definition just for the tests.

version: "2.1"tests:  build:    context: .    dockerfile: Dockerfile.tests  cmd: rspec

After your main app containers have been brought up, run

docker-compose -f docker-compose-test.yml run tests