I'm using docker in docker in my gitlab ci to run my test env and run tests in it.
In order to wait until all tests are finished I use docker wait.
tests:
image: docker:19-git
stage: tests
script:
- docker-compose -f docker-compose/my_test_env.yml up -d #setting up env
- docker-compose -f docker-compose/tests.yml up -d #running tests
- docker wait docker-compose-services_tests_1
I need to fail job if there are some problems with tests, but (docker wait docker-compose-services_tests_1
) prints container exit code and returning this exit code is considered as success operation, so job is considered as passed. docker wait
doesn't have option not to print exit code.
So I need some sh (not bash) script to run docker wait
and exit with non 0 exit code if container returns non 0 exit code (to fail the job).
What is the correct way to do this?