I'm running some tests (php-cs-fixer) inside a docker container as part of a bamboo build.
I can generate output in junit format, which I want to save as a build artifact and later process with bamboo's "JUnit Parser" task.
php-cs-fixer is not able to write to file, so I want to redirect stdout to a file, either inside the container or on the bamboo host.
I can do output redirection natively with docker, like so:
$ docker run my-docker-php-image sh -c 'vendor/bin/php-cs-fixer fix --format junit > /tmp/php-cs-fixer.xml'
Whilst typing up this question, I've got something to work. Perhaps this could be cleaned up and added to the bamboo documentation?
The docker container command is then:
sh -c '"vendor/bin/php-cs-fixer" "fix" "--dry-run" "--config=.php_cs.dist" "--using-cache=no" "--format" "junit" > /srv/artifacts/php-cs-fixer.${bamboo.buildNumber}.xml'
You need to quote the hell out of everything, and also pass the whole command through "sh -c" so that output redirection works.
Lastly, add a "JUnit Parser" task, and make it final (since the tests will not always pass)