7

I run some tests inside a docker container, at the end, test reports get generated in a directory called 'allure_test_results' and I would like those report to be available on the host machine.

1.Command in a bash file that I run as an entrypoint in a docker file:

behave -f allure_behave.formatter:AllureFormatter -o allure_test_results service/features/

2.The docker image will also be ran in Jenkins CI and I would like the same thing to happen.

3.Solutions I tried (container is not running):

docker cp <container ID>:/allure_test_results/ allure_test_results/

docker run <image id> cp /allure_test_results/:/<repo root>/allure_test_results/

PS. It would be great if the copy can be done inside dockerfile or docker-compose

I would really appreciate any help. Thank you guys so much

Aziz
  • 149
  • 3
  • 6
  • Can you map a volume (a local folder mapped to the container folder where the tests’ output is written) with the -v parameter of docker? – David Riccitelli Jan 28 '20 at 22:35

4 Answers4

2

I just figure it out. Thank you great community. I added this to docker compose file:

volumes: - ./<host dir>/:/<container dir>/allure_test_results/

Aziz
  • 149
  • 3
  • 6
2

You can map the internal directories with host directories. In simple docker use the following

docker run -v <host_directory_path>:/allure_test_results/ allure_test_results docker_image:tag

In docker compose use the volumes mapping as Aziz said.

Volumes:
  - <host_directory_path>:/allure_test_results/ allure_test_results
Cool Java guy מוחמד
  • 1,687
  • 4
  • 24
  • 40
1

Volume mounting is the option in docker :

docker run -v Jenkins _workspace path:/allure_test_results

we will map volume to jenkins workspace and the you can publish those results bin jenkins

Shubham Gorlewar
  • 404
  • 4
  • 11