Hello all,
I am experiencing a problem where Bamboo does not seem to respect the exit code from docker compose to determine whether a task was successful or not. I configured the task as described below. As you can see in the log output below, the docker-compose process exits with status 1. Bamboo ignores this status code and reports the task as success.
Bamboo task:
docker-compose -f test/docker-compose.yml up --exit-code-from tests
Where docker-compose is:
version: "3"
services:
selenium-hub:
image: ${DOCKER_REGISTRY}selenium/hub:3.141.59
container_name: selenium-hub
selenium-chrome:
image: ${DOCKER_REGISTRY}selenium/node-chrome:3.141.59
depends_on:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
selenium-firefox:
image: ${DOCKER_REGISTRY}selenium/node-firefox:3.141.59
depends_on:
- selenium-hub
environment:
- HUB_PORT_4444_TCP_ADDR=selenium-hub
- HUB_PORT_4444_TCP_PORT=4444
tests:
image: ${DOCKER_REGISTRY}node:12
command: bash -c "cp -R /data/. /workdir && npm install && npm run test"
depends_on:
- selenium-hub
- selenium-chrome
- selenium-firefox
environment:
- http_proxy=${http_proxy}
- https_proxy=${https_proxy}
- no_proxy=${no_proxy},selenium-hub,host
working_dir: /workdir
volumes:
- ${HOME:-.}/.npmrc:/root/.npmrc:ro
- ${HOME:-.}/.gitconfig:/root/.gitconfig:ro
- ${HOME:-.}/.git-credentials:/root/.git-credentials:ro
- ..:/data:ro
- ./wct.docker.conf.json:/workdir/wct.conf.json:ro
networks:
build-network:
driver: bridge
Log output:
tests_1 | npm ERR! code ELIFECYCLE
tests_1 | npm ERR! Exit status 1
test_tests_1 exited with code 1
Aborting on container exit...
Finished task 'Script' with result: Success
Hi @cambiph
I'll need more details about the task running the docker-compose command.
If you are using a script task, there is an explanation for this issue and a fix using the proper configuration.
If we consider Bash, all the commands from a script will run even if any previous command failed. The script itself (or an inline script from a script task) will by default only return the error code of the last command run. To change this behavior you need to use the set -e command to configure the terminal interpreter to stop the script if any command return a non zero error.
This is one example of a thread with a similar issue:
Moving forward
The 'set-e'-command works like a charm.
Thank you very much.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are welcome. I'm glad the issue is solved =]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ahhh I forgot to thank you for the effort on sharing a lot of meaningful information and formatting it in a way that could make my work easier when investigating this.
Thank you very much!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.